1

我想修改一个外键的更新选项。为此,我执行了以下命令:

 alter table testusers.ORDERS
 DROP CONSTRAINT ORDER_FK_2,
 ADD CONSTRAINT ORDER_FK_2 FOREIGN KEY(FK_PRODUCER_ID) REFERENCES testuser.PRODUCER      (producer_id) 
 ON UPDATE CASCADE ON DELETE CASCADE;

如果我执行此操作,则会出现以下错误:

 SQL-Fehler: ORA-01735: Ungültige Option ALTER TABLE
 01735. 00000 -  "invalid ALTER TABLE option"
4

1 回答 1

3

根据文档语法图http://docs.oracle.com/cd/B28359_01/server.111/b28286/clauses002.htm#CJAEDFIB没有逗号分隔的列表

create table orders(order_id number, fk_producer_id number, CONSTRAINT order_pk PRIMARY KEY (order_id));

create table producer(producer_id number, CONSTRAINT producer_pk PRIMARY KEY (producer_id));

alter table orders
  ADD CONSTRAINT ORDER_FK_2 FOREIGN KEY( FK_PRODUCER_ID) 
  REFERENCES PRODUCER      (producer_id) ;

alter table orders 
DROP CONSTRAINT ORDER_FK_2;

alter table orders
  ADD CONSTRAINT ORDER_FK_2 FOREIGN KEY( FK_PRODUCER_ID) 
  REFERENCES PRODUCER      (producer_id) ;

啊,是的,我也找不到任何 ON UPDATE CASCADE 语法。但我相信你现在可以解决了。否则,请发表一点评论或发布新问题。

于 2013-05-31T16:26:09.033 回答