Foreign key SQL server

Was added to a table in the database:
ALTER table Table Column name Type add null
example:
ALTER Table add the UserInfo [the Address] nvarchar (32) null

The way the code: to add a column default value constraints:
the ALTER the Table table name add constraint constraint name default (0) for DelFlag

Examples:
ALTER Table constraint DF_UserInfo_DelFlag the UserInfo the Add default (0) for delflag

table in the database and deleting a column constraint
ALTER Table drop constraint DF_UserInfo_DelFlag the UserInfo
Go
ALTER Table drop column delflag the UserInfo
Go

Modifying a column
ALTER Table drop the UserInfo column [address]
nvarchar (64) null

Product restricted number 100 ~ 0:
ALTER the Add Product constraint CK_Product_CountNumber the Check Table (CountNumber> 0 and CountNumber <100)

Adding a foreign key relationship
alter table Product add constraint EK_Product_Category foreign key (CategoryId) references Category (CatId)

Guess you like

Origin www.cnblogs.com/Mr-Prince/p/12161644.html