#1025 - Error On Rename Of Sql
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 Learn more about hiring mysql 1025 error on rename developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask
Error 1025 (hy000): Error On Rename Of
Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join error 1025 (hy000) error on rename of (errno 152) them; it only takes a minute: Sign up #1025 - Error on rename of './database/#sql-2e0f_1254ba7' to './database/table' (errno: 150) up vote 57 down vote favorite 13 So I am trying to add a primary key to one of the
Error 1025 (hy000) Error On Rename Of (errno 150)
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' (errno: 150) It is a MySQL database with InnoDB table general error 1025 error on rename of laravel 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.3k94279461 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 100 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,4401365131 answered Nov 2 '10 at 18:50 Ike Walker 33.3k95277 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 17 down vote As was said you need to remove the FKs before. On Mysql do it like this: ALTER TABLE `table_name` DROP FOREIGN KEY `id_name_fk`; ALTER TABLE `table_name` DROP INDEX `id_name_fk`; share|improve this answer edited Sep 28 at 12:31 answered Sep 4 '13 at
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 Learn
Mysql Error 1025 Errno 150
more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags
Error 1025 Outlook Mac
Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, error code 1025 outlook mac helping each other. Join them; it only takes a minute: Sign up What does mysql error 1025 (HY000): Error on rename of './foo' (errorno: 150) mean? up vote 122 down vote favorite 46 I tried this in mysql: http://stackoverflow.com/questions/4080611/1025-error-on-rename-of-database-sql-2e0f-1254ba7-to-database-table mysql> alter table region drop column country_id; And got this: ERROR 1025 (HY000): Error on rename of './product/#sql-14ae_81' to './product/region' (errno: 150) Any ideas? Foreign key stuff? mysql mysql-error-1025 share|improve this question edited Dec 5 '09 at 7:00 OMG Ponies 198k36356415 asked Oct 1 '08 at 23:33 Trenton 3,52563238 @skiphoppy - Are you trying to give a bounty to an already-given-answer? Is that even allowed? Or is your case different, in which case you should http://stackoverflow.com/questions/160233/what-does-mysql-error-1025-hy000-error-on-rename-of-foo-errorno-150-me start another thread? –Rick James Jan 9 at 6:35 @RickJames Yes it is. However, skiphoppy should add her comment under the answer she elected, as the bouty message will disappear when the bounty is over. –RandomSeed Jan 11 at 15:25 add a comment| 10 Answers 10 active oldest votes up vote 177 down vote accepted You usually get this error if your tables use the InnoDB engine. In that case you would have to drop the foreign key, and then do the alter table and drop the column. But the tricky part is that you can't drop the foreign key using the column name, but instead you would have to find the name used to index it. To find that, issue the following select: SHOW CREATE TABLE region; This should show you the name of the index, something like this: CONSTRAINT region_ibfk_1 FOREIGN KEY (country_id) REFERENCES country (id) ON DELETE NO ACTION ON UPDATE NO ACTION Now simply issue an: alter table region drop foreign key region_ibfk_1; And finally an: alter table region drop column country_id; And you are good to go! share|improve this answer answered Apr 11 '11 at 0:45 Jeshurun 13.1k44768 7 If I could upvote this twice I would. Cheers! Great walk through. –Rudiger Mar 1 '12 at 3:19 9 This should be the correct answer.Thanks! –PinoyStackOverflower Jul 17 '1
log in tour help Tour Start 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 http://dba.stackexchange.com/questions/86853/1025-error-on-rename-of-table-errno-150-table-was-deleted-while-tried-to-a Overflow the company Business Learn more about hiring developers or posting ads with us Database Administrators Questions Tags Users Badges Unanswered Ask Question _ Database Administrators Stack Exchange is a question and answer site for database http://www.shahalpk.name/post/63368393191/mysql-error-1025-on-rename-of-blahblah-errno professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer error on The best answers are voted up and rise to the top #1025 - Error on rename of table errno: 150 : Table was deleted while tried to assign foreign key up vote 1 down vote favorite When I tried to assign foreign key to a table named mydb.table1 it was deleted from my database, I could not understand the reason and tried to move on. For this tried to create same table with error on rename create SQL but it says #1005 - Can't create table 'mydb.table1' (errno: 150) Now I created same schema table with table name table2, this was successfully created but as my application code is written for table1, I need to rename this table to table1 again on which gives me following error. #1025 - Error on rename of table errno: 150 Also tried to run alter table query with set foreign_key_checks = 0. But same error. While searching I came accross below SQL, SHOW INNODB ENGINE STATUS; Which displays following message 141223 11:30:10 Error in foreign key constraint of table myahd/table1: there is no index in the table which would contain the columns as the first columns, or the data types in the table do not match the ones in the referenced table or one of the ON ... SET NULL columns is declared NOT NULL. Constraint:, CONSTRAINT "fk_key9" FOREIGN KEY ("updated_by") REFERENCES "users" ("userid") ON DELETE NO ACTION ON UPDATE NO ACTION While there is no such table listed in my database with name table1. Nor any such key is found with fk_key9. May be I can delete this table1's idb or frm file, but unable to locate it. Or may be there is some other solution. Thanks in advance. mysql innodb foreign-key share|improve
above error popped up. My SQL command was ALTER TABLE `admin_user` DROP `store_id`; and the error… MySQL Error #1025 Error on rename of '.\magento\#sql-1378_1b9' to '.\magento\admin_user' (errno: 150) I’ve learned this error is associated with some foreign key related stuff. My column store_id was a foreign key referencing another table core_store. Although the error wasn’t much informative, googling the error code will link you to pretty good results. In my case, all i have to do was to drop the associated foreign key and then drop the column. To find the foreign key name you can execute the following query select constraint_name from information_schema.key_column_usage where table_name like 'admin_user' and column_name like 'store_id'; +------------------------------------------------------------+ | constraint_name | +------------------------------------------------------------+ | FK_ADMIN_USER_WEBSITE_ID_REF_CORE_STORE_WEBSITE_ID | +------------------------------------------------------------+ Now drop the foreign key… alter table admin_user drop foreign key FK_ADMIN_USER_WEBSITE_ID_REF_CORE_STORE_WEBSITE_ID And finally drop the column… alter table `admin_user` drop `store_id`; 0 Kudos 0 Kudos Show Notes jonathanmiami liked thisjonathanmiami reblogged this from shahalpkshahalpk posted this Read this next: More shahalpk. do. overdo. @shahalpk sayhello © 2011–2016