oracle数据库创建表的时候提示缺少右括号

oracle数据库创建表的时候提示缺少右括号,第1张

试试

create table sc(

sno varchar2(8) not null references student(sno),

cno varchar2(8) not null references course(cno),

score varchar(8) not null

)

我感觉你是把constraint外键和直接外键的写法弄混了。

deptno NUMBER(2) 因为这一行的错误,应该是:deptno NUMBER(2) references dept 或者 deptno NUMBER(2) references dept(deptno)

你仅写了foreign key,就不知道你想参考哪个表(主键)了

还有另外一种写法,你将foreign key去掉,在最后一行的右括号

constraint fk_emp_deptno foreign key (deptno) references dept(或者dept(deptno),这个deptno可以省略,因为一个表只能有一个主键)


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11927002.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存