题解 | #在audit表上创建外键约束,其emp_no对应employees_test表的主键id#

在audit表上创建外键约束,其emp_no对应employees_test表的主键id

http://www.nowcoder.com/practice/aeaa116185f24f209ca4fa40e226de48


alter table audit add foreign key audit(emp_no) references employees_test(ID);

标准语法, 参考

To create a FOREIGN KEY constraint on the "PersonID" column when the "Orders" table is already created, use the following SQL:

MySQL / SQL Server / Oracle / MS Access:

ALTER TABLE Orders
ADD FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);

To allow naming of a FOREIGN KEY constraint, and for defining a FOREIGN KEY constraint on multiple columns, use the following SQL syntax:

MySQL / SQL Server / Oracle / MS Access:

ALTER TABLE Orders
ADD CONSTRAINT FK_PersonOrder
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);

To drop a FOREIGN KEY constraint, use the following SQL:

MySQL:

ALTER TABLE Orders
DROP FOREIGN KEY FK_PersonOrder;


全部评论

相关推荐

10-16 11:21
门头沟学院 Java
xdu通信dddd:我小米都面完两个月了 八月底面完的,现在还是显示面试中,没有比我恐怖的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务