Forgein key constraint in mysql. I cannot fix it? -
i created following table in mysql follow:
create table employee ( fname varchar(15) not null, minit varchar(1), lname varchar(15) not null, ssn char(9), bdate date, address varchar(50), sex char, salary decimal(10,2), superssn char(9), dno integer(4), primary key (ssn), foreign key (superssn) references employee(ssn) );
then tried insert following information:
insert employee values ("bob","b","bender","666666600", "1968-04-17","8794 garfield, chicago, il","m","96000.00","null","8");
sadly, got error:
error code: 1452. cannot add or update child row: foreign key constraint fails (`test`.`employee`, constraint `employee_ibfk_1` foreign key (`superssn`) references `employee` (`ssn`))
i tried alter table superssn
can null no solution working.
alter table employee modify column superssn char(9) default null;
"null"
not same null
. remove quotes.
Comments
Post a Comment