本文介绍了InnoDB mySQL无法设置"ON DELETE SET DEFAULT".怎么设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个名为EMPLOYEE的表.当我使用以下语句而不使用"ON DELETE SET DEFAULT"时,它正在工作.
I am trying to create a table named EMPLOYEE. When I use the following statements without "ON DELETE SET DEFAULT" it is working.
这是我在"ON DELETE SET DEFAULT"时遇到的错误:
Here is the Error I get with "ON DELETE SET DEFAULT":
ERROR 1005 (HY000): Can't create table 'COMPANY.EMPLOYEE' (errno: 150)
这里是DDL
CREATE TABLE EMPLOYEE (
Fname VARCHAR(15) NOT NULL,
Minit CHAR, Lname VARCHAR(15) NOT NULL,
Ssn CHAR(9) NOT NULL DEFAULT '123456789',
Bdate DATE, ADDRESS VARCHAR(30),
Sex CHAR, Salary DECIMAL(10,2),
Super_Ssn CHAR(9) NOT NULL DEFAULT '123456789',
Dno INT NOT NULL DEFAULT -99,
PRIMARY KEY (Ssn),
FOREIGN KEY (Super_Ssn) REFERENCES COMPANY.EMPLOYEE(Ssn)
ON DELETE SET DEFAULT
ON UPDATE CASCADE )ENGINE=InnoDB;
请帮助我!!!并预先感谢:)
Please help me!!! and Thanks in advance :)
推荐答案
您不能在InnoDB中使用ON DELETE SET DEFAULT
或ON UPDATE SET DEFAULT
You can't use ON DELETE SET DEFAULT
or ON UPDATE SET DEFAULT
with InnoDB
如果适合您,可以尝试ON DELETE SET NULL
You may try ON DELETE SET NULL
if it fits your needs
这里是 SQLFiddle 演示
Here is SQLFiddle demo
这篇关于InnoDB mySQL无法设置"ON DELETE SET DEFAULT".怎么设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!