Today, we fixed a small problem encountered in a MySQL database:
Create Table 'erp _ employee '(
'Id' int (10) unsigned not null auto_increment,
'Employee _ name' varchar (32) default null,
'User _ id' int (11) default null,
'Type' varchar (32) default null,
'Gmt _ create' timestamp not null default current_timestamp,
'Gmt _ modified' timestamp not null default '2017-01-01 00:00:00 ',
'Employee _ Tel 'varchar (64) default null,
'Employee _ sex' varchar (16) default null,
'Your _ money' double default '0 ',
'Per _ price' double default '0 ',
'Order _ num' int (10) unsigned default '0 ',
'Response _ time' int (10) unsigned default '0 ',
'Order _ no_pay' int (10) unsigned default '0 ',
'Pay _ num' int (10) unsigned not null default '0 ',
'Order _ no_pay_money 'Double not null default '0 ',
'Receive _ num' int (10) unsigned not null default '0 ',
'Order _ change_rate 'double not null default '0 ',
'Is _ deleted' varchar (2) not null default 'n ',
'Pay _ per_num 'int (11) default null,
Primary Key ('id ')
) Engine = InnoDB default charset = utf8;
Create Table 'erp _ receiver_shop '(
'Id' int (11) not null auto_increment,
'Fk _ employee_id 'int (10) Not null,
'Nick _ name' varchar (64) default null,
'Gmt _ create' timestamp not null default current_timestamp,
'User _ id' int (11) default null,
Primary Key ('id '),
Key 'fk _ employee_id '('fk _ employee_id '),
Constraint 'fk _ employee_id 'foreign key ('fk _ employee_id') References 'erp _ employee '('id') on Delete Cascade
) Engine = InnoDB default charset = utf8;
Error:
Error 1005 (hy000): Can't create table './supererpthree/# sql-2491_cceb2.frm' (errno: 150)
The main problems are:
Foreign key ('fk _ employee_id ') References 'erp _ employee' ('id ') the 'fk _ employee_id 'in the 'erp _ receiver_shop' table does not match the associated field type set by the ID in the 'erp _ employee' table, in the 'erp _ receiver_shop 'table, change 'fk _ employee_id' to 'fk _ employee_id 'int (10) unsigned not null, so no error is reported, when creating and modifying a table, you often forget this step.
Once in the past, today I made another mistake.