MySQL不能删除外键,抱错Error on rename of './ruler/test2child' to './ruler/#sql2-298-92' (errno: 152)
2007-12-22 20:57
567 查看
曾经这是MySQL的一个bug,但是现在只是MySQL的一个不友好的地方。
例子如下:
mysql> ALTER TABLE ruler.test2child DROP FOREIGN KEY test;
ERROR 1025 : Error on rename of './ruler/test2child' to './ruler/#sql2-298-8f' (errno:
152)
这里并不是不能删除外键,而是使用了错误的外键名称,但是MySQL报的错实在离谱。
正确的错误信息要如下查询才能知道:
mysql> show innodb status;
------------------------
LATEST FOREIGN KEY ERROR
------------------------
071222 20:48:26 Error in dropping of a foreign key constraint of table
"ruler"."test2child",
in SQL command
ALTER TABLE ruler.test2child DROP FOREIGN KEY test
Cannot find a constraint with the given id "test".
另外外键的其他操作也有类似情况:
比如外键 新建报错:
Can't create table 'ruler.#sql-298_92' (errno: 150)
show innodb status;
------------------------
LATEST FOREIGN KEY ERROR
------------------------
071222 20:18:57 Error in foreign key constraint of table ruler/#sql-298_8d:
FOREIGN KEY (test2code) REFERENCES ruler.test2 (test) on delete set null:
You have defined a SET NULL condition though some of the
columns are defined as NOT NULL.
测试数据库版本为:
5.2.0-falcon-alpha-community-nt
例子如下:
mysql> ALTER TABLE ruler.test2child DROP FOREIGN KEY test;
ERROR 1025 : Error on rename of './ruler/test2child' to './ruler/#sql2-298-8f' (errno:
152)
这里并不是不能删除外键,而是使用了错误的外键名称,但是MySQL报的错实在离谱。
正确的错误信息要如下查询才能知道:
mysql> show innodb status;
------------------------
LATEST FOREIGN KEY ERROR
------------------------
071222 20:48:26 Error in dropping of a foreign key constraint of table
"ruler"."test2child",
in SQL command
ALTER TABLE ruler.test2child DROP FOREIGN KEY test
Cannot find a constraint with the given id "test".
另外外键的其他操作也有类似情况:
比如外键 新建报错:
Can't create table 'ruler.#sql-298_92' (errno: 150)
show innodb status;
------------------------
LATEST FOREIGN KEY ERROR
------------------------
071222 20:18:57 Error in foreign key constraint of table ruler/#sql-298_8d:
FOREIGN KEY (test2code) REFERENCES ruler.test2 (test) on delete set null:
You have defined a SET NULL condition though some of the
columns are defined as NOT NULL.
测试数据库版本为:
5.2.0-falcon-alpha-community-nt
相关文章推荐
- MySQL不能删除外键,抱错Error on rename of './ruler/test2child' to './ruler/#sql2-298-92' (errno: 152)
- MySQL 更改表外键报错:ERROR 1025: Error on rename of .... (errno: 150)
- mysql [Err] 1025 - Error on rename of '.' to '.\\#sql2-1638-7' (errno: 121)
- ERROR 1025 (HY000): Error on rename of '.\test\#sql-c68_10' to '.\test\member' (errno: 150)
- ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.0.123' (10061)
- [ERROR] Failed to open log (file './mysql-bin.000009', errno 13)
- [MySQL生产环境复制故障修复] Last_IO_Errno: 1045 Last_IO_Error: error connecting to master 'replication@
- mysqldump Failed to open file 'xxxl', error: 22 on windows os
- MYSQL建立外键失败几种情况记录Can't create table不能创建表
- 编译海思3520内核时候报错drivers/mfd/ezx-pcap.c:205:2: error: implicit declaration of function 'irq_to_gpio' [-
- jsf配置问题 Error performing conversion of value ' of type class java.lang.String to type class
- Error: Failed to connect to MySQL server: DBI connect(';
- ERROR 1130: Host 'A'is not allowed to connect to this MySQL server
- 关于error:Cannot assign to 'self' outside of a method in the init family
- 这个惊叹号不能少,否则引发“syntax error `end of file' unexpected”的错误
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
- ERROR 1044 (42000):Access denied for user ''@'localhost' to database 'mysql'的解决方法
- A possible solution of MySQL workbench cannot connect to local host error on MAC
- mysql:ERROR 1130: Host '192.168.0.102' is not allowed to connect to this MySQL server
- drivers/input/touchscreen/eeti_ts.c:65:2: error: implicit declaration of function 'irq_to_gpio'