Home:ALL Converter>Add multiple foreign keys to existing table in Oracle

Add multiple foreign keys to existing table in Oracle

Ask Time:2021-07-06T12:45:39         Author:Rosh

Json Formatter

I want to add multiple foreign keys to existing table in Oracle database. Following sql query gives me an error. One by one I can add foreign key constraint. But I want to do this within one statement like below.

ALTER  TABLE address                                                                                                  
ADD  CONSTRAINT fk_customer_id FOREIGN KEY (customer_id) 
     REFERENCES  customer (id) ON  DELETE CASCADE ,
ADD  CONSTRAINT fk_city_id     FOREIGN KEY (city_id) 
     REFERENCES  city (id) ON  DELETE  CASCADE;

Any idea how to do this?

Author:Rosh,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/68264667/add-multiple-foreign-keys-to-existing-table-in-oracle
yy