+---------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(64) | NO | | NULL | |
-----------------------------------------------------------------------
表2
ALTER TABLE Table2
ADD COLUMN person_id int(11),
ADD FOREIGN KEY fk_person_id(person_id) references Table(id);
這給我一個錯誤,
ERROR 1005(HY000):能't create table'table2。#sql-3fb_7cf'(errno:150)
表1 id
的主鍵是正確的。還有哪些地方失敗?
您的表格實際上是否名爲'表'? – 2014-10-20 22:26:11