oracle 刪除外來鍵約束 禁用約束 啟用約束

2021-07-08 19:22:12 字數 558 閱讀 9626

執行以下sql生成的語句即可

刪除所有外來鍵約束 

sql**  

select

'alter table '||table_name||' drop constraint '||constraint_name||';'

from user_constraints where constraint_type='r'

禁用所有外來鍵約束

sql**  

select

'alter table '||table_name||' disable constraint '||constraint_name||';'

from user_constraints where constraint_type='r'

啟用所有外來鍵約束

sql**  

select

'alter table '||table_name||' enable constraint '||constraint_name||';'

from user_constraints where constraint_type='r'

oracle啟用 禁用 刪除外來鍵

禁用所有外來鍵約束 select alter table table name disable constraint constraint name from user constraints where constraint type r and status enabled 啟用所有外來鍵約束 ...

刪除外來鍵約束

主表 create table test1 id int primary key not null,value int insert test1 select 1,2 go 從表 create table test2 id int references test1 id value int go 第...

mysql級聯刪除外來鍵約束 主外來鍵和外來鍵約束

主鍵 primary key 一列 或一組列 其值能夠唯一區分表中每個行 外來鍵 foreign key 外來鍵為某個表中的一列,它包含另乙個表的主鍵值,定義了兩個表之間的關係 右邊的departmentid是外來鍵。外來鍵約束是指用於在兩個表之間建立關係,需要指定引用主表的哪一列。on delet...