我有两张桌子:tab1,tab2
我想给 tab2 添加一个外键并写了这个查询
ALTER TABLE tab2
ADD FOREIGN KEY(name) REFERENCES tab1(name)
但我得到这个错误:
error 1005(HY000):can't create table 'club.#sql-6f0_2' (errno:150)
怎么了?
Edit
i write this tables only for test.
tab1
name char(20) private key
lname char(20)
tab2
ssn int private key
name char(20)