首页 > 代码库 > mssql2000数据库执行SQL语句来创建数据库以及数据表还有索引

mssql2000数据库执行SQL语句来创建数据库以及数据表还有索引

mssql2000数据库执行SQL语句来创建数据库以及数据表还有索引

创建数据库MSsql2000
Create DATABASE databasename on primary

(name=‘databasename_data‘,filename=‘C:\databasename_data.mdf‘,size=3mb,maxsize=UNLIMITED,filegrowth=10%)log on

(name=‘databasename_log‘,filename=‘C:\databasename_log.ldf‘,size=3mb,filegrowth=10%)

CREATE DATABASE [dbname] ON  PRIMARY ( NAME = N‘dbname_data‘, FILENAME = N‘C:\dbname_data.mdf‘ , SIZE = 3072KB , MAXSIZE =

UNLIMITED ,FILEGROWTH = 1024KB )LOG ON ( NAME = N‘dbname_log‘, FILENAME = N‘C:\dbname_log.ldf‘ , SIZE = 1024KB , MAXSIZE =

UNLIMITED ,FILEGROWTH = 10%) COLLATE Chinese_PRC_90_CS_AI


删除数据库
drop database databasename

创建数据表
CREATE TABLE [dbo].[t_rewards] (
 [id] [int] IDENTITY (1, 1) NOT NULL ,
 [itemname] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
 [itemnum] [int] NULL ,
 [radbig] [int] NULL ,
 [radsmall] [int] NULL ,
 [uptable] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
 [uptype] [tinyint] NULL
) ON [PRIMARY]

创建主键 Alter table t_rewards add primary key(id)
删除主键 Alter table t_rewards drop primary key(id)


创建索引 create unique index PK_t_rewardsuptype on t_rewards(uptype)
删除索引 drop index PK_t_rewardsuptype on t_rewards
删除索引 drop index t_rewards.PK_t_rewardsuptype

创建唯一索引 alter table t_rewards add constraint PK_t_rewardsitemname unique(itemname)

 

mssql2000数据库执行SQL语句来创建数据库以及数据表还有索引