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