if exists (select 1 from sysobjects where id = object_id('dwlx') and type = 'u') drop table dwlxgo/*==============================================================*//* table: dwlx *//*========================================================
if exists (select 1 from sysobjects where id = object_id('dwlx') and type = 'u') drop table dwlxgo/*==============================================================*//* table: dwlx *//*==============================================================*/create table dwlx ( dwlx_nm varchar(36) not null, dwlx_lxbh varchar(6) not null, dwlx_lxmc varchar(64) not null, dwlx_level int not null, dwlx_fjnm varchar(36) not null, dwlx_mx char(1) not null, constraint pk_dwlx primary key nonclustered (dwlx_nm))go
分析constraint pk_dwlx primary key nonclustered (dwlx_nm)这句话:
对表dwlx建立主键约束,主键约束的名字是:pk_dwlx ,主键列是:dwlx_nm。
primary key 约束默认为 clustered;unique 约束默认为 nonclustered。此处指明该表为nonclustered索引(即非聚集索引)。
小注:
1、sql server判断某个表是否存在:点击打开链接。
2、sql server中clustered与nonclustered的区别 :点击打开链接。
3、go的意思是本语句块结束的意思,一遇到go就直接提交到存储引擎。
go (transact-sql)官方文档:点击打开链接
