Mysql 外键约束在drop table上失败,即使;“删除时设置为空”;设定

Mysql 外键约束在drop table上失败,即使;“删除时设置为空”;设定,mysql,Mysql,我有一张桌子 create table if not exists Emp( PId int not null primary key auto_increment, DId int, Name varchar(30) not null, LastName varchar(30) not null) 及 当我试图删除表Emp时,我得到了:“无法删除或更新父行:外键约束失败”。 这个代码有什么问题?为什么ON DELETE无法正常工作?ON DELETE是关于在引用表中删除时的行

我有一张桌子

create table if not exists Emp(
  PId int not null primary key auto_increment,
  DId int,
  Name varchar(30) not null,
  LastName varchar(30) not null)

当我试图删除表Emp时,我得到了:“无法删除或更新父行:外键约束失败”。
这个代码有什么问题?为什么ON DELETE无法正常工作?

ON DELETE
是关于在引用表中删除时的行为
DROP
DELETE
是不同的东西。因此,正确的方法是先降低工资,还是只删除约束?
create table if not exists Wages(
  ZId int not null primary key auto_increment,
  PId int,
  amount int not null,
  FOREIGN KEY (PId) REFERENCES Emp(PId) ON DELETE SET NULL ON UPDATE SET NULL)