例如
create table time
(
time_emp number(3) NOT NULL CONSTRAINT time_emp_FK references employee(emp_id)
);有一个错误....如何在一行中同时编写not null和constraint??
发布于 2016-04-29 20:31:06
如果您的数据库是Oracle,则可以使用上面的语句。只需确保employee表中的emp_id包含unique或primary key约束。
发布于 2016-12-01 02:39:22
我使用的是MySql服务器,当我在MySql中只声明了一列外键,而不是null时,它给出了错误,但当我将它与另一列一起使用时,它对我来说很好,我的答案是:
create table table1(id int(20) NOT NULL,PRIMARY KEY(id));
create table table2(id int(20) NOT NULL,pid int(20),PRIMARY KEY(id),FORIEGN KEY(pid) references table1(id));https://stackoverflow.com/questions/36938292
复制相似问题