SQL查询Alter Table MySql时出错
执行以下查询时出现错误:
ALTER TABLE property_res_details
ADD CONSTRAINT PropertyIdLink FOREIGN KEY ( Property_ID )
REFERENCES properties( Property_ID ) ON DELETE CASCADE ;
#1005 - Can't create table './resfi/#sql-10e1_8df.frm' (errno: 150)
我可能做错了什么?
I get an error when executing the below query:
ALTER TABLE property_res_details
ADD CONSTRAINT PropertyIdLink FOREIGN KEY ( Property_ID )
REFERENCES properties( Property_ID ) ON DELETE CASCADE ;
#1005 - Can't create table './resfi/#sql-10e1_8df.frm' (errno: 150)
What might I be doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个page 可能会提供有关正在发生的情况的线索...
由于您要添加外键,因此听起来很相关。
它建议您尝试
查看最新的约束错误,这可能会导致您看到的错误。
也许如果您在命令之前尝试
,它会禁用检查并允许您继续?
This page might give a clue as to what's going on...
Since you're adding a foreign key, it sounds relevant.
It suggests you try
to see the latest constraint error which may cause the error you're seeing.
Maybe if you try
before your command, it will disable the checks and allow you to continue?
是的,您难道不喜欢 MySQL 令人敬畏的错误消息吗?
确保两个表中的
Property_ID
列具有完全相同的数据类型。这就是我过去为自己修复类似错误的方法。Yeah, don't you just love MySQL's awesome error messages.
Make sure that the
Property_ID
columns have the exact same datatype in both tables. That's how I have fixed similar errors for myself in the past.