2015-12-03 80 views
0
alter table booking 
add constraint fk_customer_id 
foreign key customer_id 
references customer (customer_id); 

有什麼問題,有人可以幫忙嗎?ORA-00906:缺少左括號(FK)

+0

這表明您需要爲「FK」添加左括號;因爲「fk」只出現一次,所以它必須在需要左paren的「fk_customer_id」之前。請參閱http://www.dba-oracle.com/t_alter_table_add_constraint_syntax_example.htm –

+0

我不是Oracle頭,但外鍵是否需要大寫FOREIGN KEY? –

+0

@ B.ClayShannon,註冊不重要 – HAYMbl4

回答

4

嘗試括號周圍字段名

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

您需要周圍的源字段名方括號,並在整個約束爲ALTER TABLE ADD的一部分(..your除了這裏...)語法

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

修改對 - 外支架僅要求若加入多個項目,所以給出正確答案andraemc但要注意可能需要鄰子宮括號。我始終堅持保持風格一致,所以我永遠不會忘記!