MySQL外來鍵約束的禁用與啟用命令

2022-09-25 22:15:13 字數 367 閱讀 4507

mysql外來鍵約束的禁用與啟用:

mysql外來鍵約束是否啟用是通過乙個全域性變數標示的:

fqtrnhhehfqoreign_key_chec程式設計客棧ks=0; 禁用狀態

foreign_key_checks=1; 啟用狀態

檢視當前foreign_key_checks的值可用程式設計客棧如下命令:

se程式設計客棧lect @@foreign_key_checks;

禁用外來鍵程式設計客棧約束:

set foreign_key_checks=0;

啟用外來鍵約束:

set foreign_key_checks=1;

本文標題: mysql外來鍵約束的禁用與啟用命令

本文位址:

mysql約束與外來鍵 MySQL 外來鍵與約束

外來鍵的建立 建表如下 create table parent id int not null,primary key id type innodb create table child id int,parent id int,foreign key parent id references pa...

SqlServer禁用啟用觸發器 外來鍵約束

啟用or禁用指定表所有外來鍵約束 alter table tbname nocheck constraint allalter table tbname check constraint all 檢視約束 select name is disabled from sys.foreign keys o...

MySQL 啟動和禁用外來鍵約束

在mysql中刪除一張表或一條資料的時候,出現 err 1451 cannot delete or update a parent row a foreign key constraint fails 這是因為mysql中設定了foreign key關聯,造成無法更新或刪除資料。可以通過設定fore...