删除数据库,SQL Server将数据库的清单存放在master系统数据库的sysdatabases表中,只需要查看该表是否存在于该数据库中就可以了,语句如下:
use master -- 设置当前数据库为master,以便访问sysdatabases表
go
if exists (select * from sysdatabases where name='practice')
drop database practice
创建表的SQL语句如下:
use practice
go
if exists (select * from sysobjects where name='practice')
drop table Store_Information
create table Store_Information
(
storeID int identity(1,1) primary key,--列属性"identity(起始值,递增量)"
store_Name varchar not null,
store_Money decimal null,
store_Date date not null,
)