ORA-00906:缺少左括号(FK)

时间:2015-12-03 16:52:06

标签: sql oracle command foreign-keys

alter table booking 
add constraint fk_customer_id 
foreign key customer_id 
references customer (customer_id);

问题是什么,有人可以帮忙吗?

2 个答案:

答案 0 :(得分:4)

尝试围绕字段名称的parens

alter table booking 
add constraint fk_customer_id 
foreign key (customer_id) 
references customer (customer_id);

答案 1 :(得分:1)

你需要在源字段名称周围使用括号,并在整个约束周围添加 alter table add(..你们在这里添加......) 语法< / p>

alter table booking add
( 
   constraint fk_customer_id 
   foreign key (customer_id )
   references customer (customer_id)
);

修改 - 只有在添加多个项目时才需要外部括号,因此请给出正确的答案,但要注意可能需要外部括号。我总是坚持以保持风格一致,所以我永远不会忘记!