【文章內(nèi)容簡(jiǎn)介】
50) not null,Upassword varchar(50) not null, U varchar(50), Usex char(2) not null, Uclass int, Uremark varchar(50),UregDate datetime not null, Ustate int,Upoint int, ) go 為bbsUsers表添加各種約束alter table bbsUsers add constraint PK_UID primary key(UID) alter table bbsUsers add constraint CK_Upassword check(len(Upassword) = 6) alter table bbsUsers add constraint DF_Upassword default(39。00000039。) for Upassword alter table bbsUsers add constraint CK_U check(U like 39。%@%39。) alter table bbsUsers add constraint DF_Usex default(39。男39。) for Usex alter table bbsUsers add constraint CK_Usex check(Usex=39。男39。 or Usex=39。女39。) alter table bbsUsers add constraint DF_Uclass default(1) for Uclass alter table bbsUsers add constraint DF_UregDate default(getDate()) for UregDate alter table bbsUsers add constraint DF_Ustate default(0) for Ustate alter table bbsUsers add constraint DF_Upoint default(20) for Upoint 以上信息為以建立的bbsUser(用戶(hù)表)及各種約束go 新建bbsSection表(版塊表) if exists(select * from sysobjects where name = 39。bbsSection39。) drop table bbsSection create table bbsSection ( SID int identity(1,1) not null, Sname varchar(50) not null, SmasterID int not null, Sprofile varchar(50), SclickCount int,StopicCount int ) go 為表bbsSection(版塊表)添加約束 alter table bbsSection add constraint PK_SID primary key(SID) alter table bbsSection add constraint FK_SmasterID foreign key(SmasterID) references bbsUsers (UID) alter table bbsSection add constraint DF_SclickCount default(0) for SclickCount alter table bbsSection add constraint DF_StopicCount default(0) for StopicCount 以上為表bbsSection(版塊表)建立及添加相應(yīng)約束 go新建bbsTopic表(主貼表) if exists(select * from sysobjects where name = 39。bbsTopic39。) drop table bbsTopic create table bbsTopic ( TID int identity(1,1) not null, TsID int not null, TuID int not null,TreplyCount int, Tface int, Ttopic varchar(50) not null, Tcontents varchar(50) not null,Ttime datetime, TclickCount int,Tstate int not null,TlastRe