Guys my question is I don't know the constraint names that I've added to a table. But I need to remove or disable all those foreign key constraints. But how?
SQL> desc orders;
Name Null? Type
----------------------------------------- -------- ----------------------------
ORDER_ID NOT NULL VARCHAR2(10)
PRODUCT_ID VARCHAR2(10)
DATE_OF_ORDER TIMESTAMP(6)
CUST_ID VARCHAR2(10)
QUANTITY NUMBER(38)
TOTAL_PRICE FLOAT(10)
DELIVERY_STATUS VARCHAR2(10)
CodePudding user response:
The related foreign constraints might be determined by using user_constraints
dictionary view, and you can disable the foreign key constraint of this table by the following code block
BEGIN
FOR c IN
(
SELECT *
FROM user_constraints c
WHERE c.constraint_type = 'R'
AND c.table_name = 'ORDERS')
LOOP
EXECUTE IMMEDIATE 'ALTER TABLE '||c.table_name||
' DISABLE CONSTRAINT '||c.constraint_name;
END LOOP;
END;
/
CodePudding user response:
If you're using a tool like sql developer you can just right click the table name in the navigator and select constraint > disable all or drop