MySQL alter table - 将 TINYINT 更改为 SMALLINT
我有以下数据库,其中有两个表(请原谅我丑陋的格式):
TABLE_A : Id TINYINT, PRIMARY KEY (Id)
TABLE_B : Id TINYINT, FOREIGN KEY (Id) REFERENCES TABLE_A (Id)
我想修改 Id,使其成为 SMALLINT 而不是 TINYINT。以下是一些失败的尝试:
mysql> ALTER TABLE TABLE_A MODIFY Id SMALLINT
ERROR 1025 (HY000): Error on rename of '.\testdb\#sql-bcc_16' to '.\testdb\table_a' (errno: 150)
mysql> ALTER TABLE TABLE_B DROP FOREIGN KEY (Id)
ERROR 1025 (HY000): Error on rename of '.\testdb\table_b' to '.\testdb\#sql2-bcc-16' (errno: 152)
有谁知道这里发生了什么?
I have the following database with two tables (excuse my ugly format):
TABLE_A : Id TINYINT, PRIMARY KEY (Id)
TABLE_B : Id TINYINT, FOREIGN KEY (Id) REFERENCES TABLE_A (Id)
I would like to modify Id so that it's a SMALLINT rather than a TINYINT. Here are a couple failed attempts:
mysql> ALTER TABLE TABLE_A MODIFY Id SMALLINT
ERROR 1025 (HY000): Error on rename of '.\testdb\#sql-bcc_16' to '.\testdb\table_a' (errno: 150)
mysql> ALTER TABLE TABLE_B DROP FOREIGN KEY (Id)
ERROR 1025 (HY000): Error on rename of '.\testdb\table_b' to '.\testdb\#sql2-bcc-16' (errno: 152)
Does anyone know what's going on here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用下面的查询
mysql> ALTER TABLE Price MODIFY Id SMALLINT
mysql> ALTER TABLE Sale MODIFY Id SMALLINT
mysql> ALTER TABLE Phone MODIFY Id SMALLINT
我也回答了
MySQL alter table 生成“重命名错误”很久以前..但你没有在那里回复...
在你的情况下它将是
mysql>; ALTER TABLE TABLE_A MODIFY Id SMALLINT
mysql> ALTER TABLE TABLE_B MODIFY Id SMALLINT
更新
检查帮助:错误 1025 (HY000):重命名时出错.... (errno: 150).. 可能对你有帮助..
Use below queries
mysql> ALTER TABLE Price MODIFY Id SMALLINT
mysql> ALTER TABLE Sale MODIFY Id SMALLINT
mysql> ALTER TABLE Phone MODIFY Id SMALLINT
I also answered it at
MySQL alter table generating "error on rename" long time back... but you are not replying there...
Here in your case it will be
mysql> ALTER TABLE TABLE_A MODIFY Id SMALLINT
mysql> ALTER TABLE TABLE_B MODIFY Id SMALLINT
Update
check Help with: ERROR 1025 (HY000): Error on rename of .... (errno: 150).. Might help you..