外键约束
在Mssql2005在创建表时,可以这样的创建外键
create table Orders
(
OrderID int identity not null Primary key,
CustomerID int not null foreign key references Customers(CustomerNo),//customers是提供外键约束的表,customerNo是提供外键的列
OderDate smalldatetime not null,
EmployeeID int not null
)
当表创建完毕后,也可以这样的追加外键约束
alter table Orders
add constraint FK_EmployeeCreateOrder
foreign key(EmployeeID) references employees(EmployeeID)