mysql外键似乎出错
create table t_termi_client
(
id int,
pid int,
termi_client_level_id char(5),
termi_name varchar(40) not null,
contact_tel varchar(30),
adress varchar(30),
zip_code varchar(50),
is_leaf char(6) not null,
is_termi_client char(1) not null,
primary key (id)
);
alter table t_termi_client add constraint fk_id_pid foreign key (pid)
references t_termi_client (id) on delete restrict on update restrict;
ERROR 1005 (HY000): Can't create table 'erp.#sql-e30_3' (errno: 121)
还有一个外键 链接其他表 但是显示没问题
alter table t_termi_client add constraint fk_client__level_data foreign key (termi_client_level_id)
references t_data_diet (id) on delete restrict on update restrict;
不懂 这个外键错在了那里··
单独创建一个库 使用上面的语句就没有错误
mysql> create table t_termi_client
-> (
-> id int,
-> pid int,
-> termi_client_level_id char(5),
-> termi_name varchar(40) not null,
-> contact_tel varchar(30),
-> adress varchar(30),
-> zip_code varchar(50),
-> is_leaf char(6) not null,
-> is_termi_client char(1) not null,
-> primary key (id)
-> );
Query OK, 0 rows affected (0.01 sec)
mysql> alter table t_termi_client add constraint fk_id_pid foreign key (pid)
-> references t_termi_client (id) on delete restrict on update restric
t;
Query OK, 0 rows affected (0.04 sec)
Records: 0 Duplicates: 0 Warnings: 0