sql 在界面中如何设外键

来源:百度知道 编辑:UC知道 时间:2024/05/29 05:57:42
我是初学者,能说的详细点吗?

primary key 是一个表中的主键,你在另一个表中,同样的字段,你用foreign key references 表一(字段)
例如:(在查询分析器中的代码)
creat table table1(ID int primary key)
creat table table2(ID int foreign key references table1(ID))

你是sqlserver吗?
用企业管理器登进去,然后选择表-->设计表-->管理关系

在里面选择表。字段就好了