0

我正在尝试创建一个以 varchars 作为主键和外键的自联接表。表创建但我在尝试将数据插入表时不断收到错误

桌子

 CREATE TABLE `staff` (
`staff_id` VARCHAR(255) NOT NULL,
`name` VARCHAR(255) NULL DEFAULT NULL,
`email` VARCHAR(255) NULL DEFAULT NULL,
`manager_id` VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (`staff_id`),
FOREIGN KEY (`manager_id`) REFERENCES `staff` (`staff_id`))

数据转储

   /*Data for the table `staff` */
  INSERT INTO staff (STAFF_ID, NAME, EMAIL, MANAGER_ID)
  VALUES ('lo1234', 'test','**.com', null);
 INSERT INTO staff (STAFF_ID, NAME, EMAIL, MANAGER_ID)
  VALUES ('er8909', 'test2','**.com', 'l01234');
 INSERT INTO staff (STAFF_ID, NAME, EMAIL, MANAGER_ID)
 VALUES ('ru6758', 'r**','**.com', 'l01234');
 INSERT INTO staff (STAFF_ID, NAME, EMAIL, MANAGER_ID)
 VALUES ('ad4567', 'admin','**.com', null);

架构的构造或插入的数据有问题吗?

4

1 回答 1

4

你在这行做错了1o12341012345因为

INSERT INTO staff (STAFF_ID, NAME, EMAIL, MANAGER_ID)
          VALUES ('lo1234', 'test','**.com', null);

将其更改为:

INSERT INTO staff (STAFF_ID, NAME, EMAIL, MANAGER_ID)
  VALUES ('l01234', 'test','**.com', null);
于 2013-04-27T10:16:23.843 回答