简体   繁体   中英

How to delete all the FOREIGN KEY Constraint?

I have 3 FOREGIN Keys in my table.

Here is my table:

create table rooms (
    room_id NUMBER(5)
    CONSTRAINT rooms_room_id_pk PRIMARY KEY,
    hotel_id NUMBER(10)
    CONSTRAINT rooms_hotel_id_fk REFERENCES hotel(hotel_id),
    avaliability VARCHAR2(10)
    CONSTRAINT rooms_avaliability_nn NOT NULL,
    staff_id NUMBER(10)
    CONSTRAINT rooms_staff_id_fk REFERENCES staffs(staff_id),
    room_type_id NUMBER(10)
    CONSTRAINT rooms_room_type_id_fk REFERENCES room_type(room_type_id)
)
/

I've been searching online on how to remove it but to no avail.

These are the codes I put in,

ALTER TABLE rooms
DROP CONSTRAINT room_type(room_type_id)

I want to remove the foreign key contraint but I keep getting invalid alter table option. Any idea where I go wrong?

ALTER TABLE rooms
DROP FOREIGN KEY room_type_id

This would work will drop the foreign key set on room_type_id

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM