T-SQLDDL:–进入某个数据库use TestBasego–创建表create table ProductInfos(Id int identity(1001,1) primary key not null,ProNo varchar(50) unique not null,ProName nvarchar(20) not null,TypleId int not null,foreign key references ProductType(TypeId),Price decimal(18,2) check (Price<10000) default(0.00) not null,ProCount int default (0) null,)go–删除表drop table ProductInfosgo–在建表完成后,创建约束Create table ProductInfos(Id int identity(1001,1) not null, --标识种子,–主键 Idalter table ProductInfos add constraintPK_ProductInfos primary key(Id)–外键 TypeIdalter table ProductInfos add constraintFK_ProductInfos foreign key (TypeId) referencesProductType(TypeId)–unique约束 ProNoAlter table ProductInfos add constraintIX_ProductInfos_ProNo unique(ProNo)–unique ProNo+ProNameAlter table ProductInfos add constraintIX_ProductInfos_ProNo unique (ProNo,ProName)–check 约束alter table ProductInfos add constraintCK_ProductInfos_Price check(Price<10000)–default 约束alter table ProductInfos add constraint DF_ProCountdefault (0) for ProCount<}