Error 1025 Error On Rename Of
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business mysql error on rename Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation
Mysql Error 1025 (hy000) Error On Rename Of
Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like error 1025 (hy000) error on rename of (errno 152) you, helping each other. Join them; it only takes a minute: Sign up #1025 - Error on rename of './database/#sql-2e0f_1254ba7' to './database/table' (errno: 150) up vote 58 down vote favorite 13 So I am trying to add
Error 1025 (hy000) Error On Rename Of (errno 150)
a primary key to one of the tables in my database. Right now it has a primary key like this: PRIMARY KEY (user_id, round_number) Where user_id is a foreign key. I am trying to change it to this: PRIMARY KEY (user_id, round_number, created_at) I am doing this in phpmyadmin by clicking on the primary key icon in the table structure view. This is the error I get: #1025 - Error on rename of './database/#sql-2e0f_1254ba7' to './database/table' general error 1025 error on rename of laravel (errno: 150) It is a MySQL database with InnoDB table engine. mysql sql phpmyadmin innodb mysql-error-1025 share|improve this question edited Apr 30 '11 at 17:29 OMG Ponies 198k36356415 asked Nov 2 '10 at 17:55 Richard Knop 23.4k95284462 1 A quick search using Google gives me the idea that this problem is related to constraints. Possible helpful links: dev.mysql.com/doc/refman/5.0/en/innodb-error-codes.html and simplicidade.org/notes/archives/2008/03/mysql_errno_150.html –Lekensteyn Nov 2 '10 at 18:01 add a comment| 6 Answers 6 active oldest votes up vote 101 down vote accepted There is probably another table with a foreign key referencing the primary key you are trying to change. To find out which table caused the error you can run SHOW ENGINE INNODB STATUS and then look at the LATEST FOREIGN KEY ERROR section. share|improve this answer edited Nov 20 '14 at 11:00 trejder 6,4601365131 answered Nov 2 '10 at 18:50 Ike Walker 33.4k95278 add a comment| up vote 18 down vote For those who are getting to this question via google... this error can also happen if you try to rename a field that is acting as a foreign key. share|improve this answer answered Jun 20 '13 at 13:03 Dave C 262521 add a comment| up vote 18 down vote As was said you need to remove the FKs before. On Mysql do it like this: ALTER TABLE `table_name` DROP FOREIGN K
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this
Mysql Error 1025 Errno 150
site About Us Learn more about Stack Overflow the company Business Learn more
Error 1025 Outlook Mac
about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x error code 1025 outlook mac Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Help with: http://stackoverflow.com/questions/4080611/1025-error-on-rename-of-database-sql-2e0f-1254ba7-to-database-table ERROR 1025 (HY000): Error on rename of … (errno: 150) up vote 35 down vote favorite 7 I am getting this error when I am trying to run an alter table command to drop a column: ERROR 1025 (HY000): Error on rename of .... (errno: 150). If I understand correctly it is a foreign key problem, but I do not have a clue how http://stackoverflow.com/questions/5948704/help-with-error-1025-hy000-error-on-rename-of-errno-150 to fix it. Would somebody be so kind and tell me how to get it working. The code used for creating table: CREATE TABLE categories( cid INT AUTO_INCREMENT NOT NULL PRIMARY KEY, assets_id INT NOT NULL, cat_name VARCHAR(30) NOT NULL, INDEX(assets_id), FOREIGN KEY (assets_id) REFERENCES asset(aid) ON UPDATE CASCADE ) ENGINE=INNODB DEFAULT CHARSET=utf8; The alter command: ALTER TABLE categories DROP COLUMN assets_id; The table categories is completely blank. So there is no information to set off the CASCADE restrictions. So could you help me what kind of wizardry do I need to delete the column assets_id. Thank you. mysql share|improve this question edited May 10 '11 at 10:50 Manoj 3,42564364 asked May 10 '11 at 10:31 Henkka 3623817 add a comment| 3 Answers 3 active oldest votes up vote 66 down vote accepted Use SHOW CREATE TABLE categories to show the name of constraint. Most probably it will be categories_ibfk_1 Use the name to drop the foreign key first and the column then: ALTER TABLE categories DROP FOREIGN KEY categories_ibfk_1; ALTER TABLE categories DROP COLUMN assets_id; share|improve this answer answered May 10 '11 at 10:37 Quassnoi 261k50430482 Thank y
Hugo. RSS Feed. Baron Schwartz's Blog MySQL's ERROR 1025 explained Tue, Aug 22, 2006 in Databases MySQL issues a http://www.xaprb.com/blog/2006/08/22/mysqls-error-1025-explained/ cryptic error message, “Error on rename,” when you try to alter a table in such a way that it would break a foreign key constraint: http://laravel.io/forum/03-22-2014-migratereset-erring-when-dropping-foreign-key create table test1(a int not null primary key)engine=innodb; create table test2(a int not null, foreign key(a) references test1 (a)) engine=innodb; alter table test2 modify a error 1025 smallint not null; ERROR 1025 (HY000): Error on rename of './test/#sql-2fa8_1' to './test/test2' (errno: 150) This happens because ALTER TABLE really works by making a copy of the table, then renaming to move the old table out of the way and move the new table into its place. It is error on rename certainly one of the less meaningful error messages I’ve seen in MySQL. There’s slightly more information in the output of SHOW ENGINE INNODB STATUS, if you are looking there (of course, if you’re looking there you’re probably already clued in to what’s going on). And innotop can parse that information for you: In case you didn’t understand why the foreign key constraint was failing, the error message innotop parses out is much clearer. It’s because the foreign key columns in the parent and child table have to have the same data type. I was trying to change the child’s column to an incompatible type. I'm Baron Schwartz, the founder and CEO of VividCortex. I am the author of High Performance MySQL and many open-source tools for performance analysis, monitoring, and system administration. I contribute to various database communities such as Oracle, PostgreSQL, Redis and MongoDB. Newer Older Comments
Local Community Meetups Laravel.io Site and Community Forum Database migrate:reset erring when dropping foreign key I'm having an issue when rolling back a migration that drops foreign keys. I'm creating the foreign keys in their own migration file to avoid any issues with the tables not being present and the migration itself works fine. However, the reset provides the following SQL error. [Illuminate\Database\QueryException] SQLSTATE[HY000]: General error: 1025 Error on rename of [emailprotected]/authors_books' to [emailprotected]/#sql2 20a-f4' (errno: 152) (SQL: alter table `authors_books` drop foreign key author_id) Everything seems fine. I'll include a sample migration set that I'm using to isolate the problem. I'm kind of stumped though. Could anyone offer some insight? 2014_03_22_162022_create_table_authors.php