Mysql Drop Column Error On Rename
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 developers error 1025 (hy000) error on rename of (errno 152) or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question mysql error 1025 errno 150 x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; error 1025 outlook mac it only takes a minute: Sign up What does mysql error 1025 (HY000): Error on rename of './foo' (errorno: 150) mean? up vote 123 down vote favorite 47 I tried this in mysql: mysql> alter table region drop column country_id;
Error Code 1025 Outlook Mac
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 199k37360417 asked Oct 1 '08 at 23:33 Trenton 3,56063238 @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 start another thread? –Rick James Jan 9 at 6:35 how to drop foreign key in mysql @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 181 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.3k45069 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 '12 at 14:12 You saved my bacon. Thanks for this answer. I have seen similar solutions via google sear
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 developers or posting mysql rename foreign key ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join
Alembic Drop Foreign Key
the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a
Laravel Drop Foreign Key
minute: Sign up #1025 - Error on rename (errno: 150) in mysql up vote 8 down vote favorite 1 I am trying to drop a foreign key(id) in one table(misc) which is the primary key(id) in table(main). db name(xxx) alter table http://stackoverflow.com/questions/160233/what-does-mysql-error-1025-hy000-error-on-rename-of-foo-errorno-150-me misc drop FOREIGN KEY id I am getting this error #1025 - Error on rename of '.\interview#sql-edc_27' to '.\interview\misc' (errno: 150) mysql share|improve this question edited Oct 29 '13 at 20:43 juergen d 126k21133198 asked Oct 29 '13 at 20:42 black 69131224 possible duplicate of #1025 - Error on rename of './database/#sql-2e0f_1254ba7' to './database/table' (errno: 150) –Kermit Oct 29 '13 at 20:50 add a comment| 2 Answers 2 active oldest votes up vote 14 down vote accepted SHOW CREATE TABLE http://stackoverflow.com/questions/19668682/1025-error-on-rename-errno-150-in-mysql misc ; You can't drop the foreign key using the column name,run the above query to find out the correct name,something like misc_ibfk_1 Heh,IT IS this name: alter table misc drop FOREIGN KEY misc_ibfk_1 share|improve this answer answered Oct 29 '13 at 20:50 Mihai 15.3k52542 ALTER TABLE misc DROP COLUMN id to drop column . thanks –black Oct 29 '13 at 21:00 add a comment| up vote 1 down vote In my case, was necessary to make a 3-step process (my table is named "articulos", and the hard-to-remove index is "FK_Departamento_ID") For knowing the name of table, I executed: SHOW INDEX FROM articulos; This statement resolved the issue (#1025, errno: 150), but the index remained in the table ALTER TABLE articulos DROP FOREIGN KEY FK_Departamento_ID; The following statement finally wiped out the index DROP INDEX FK_Departamento_ID ON articulos; share|improve this answer answered Sep 11 '15 at 15:58 ZooMMX 4917 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagged mysql or ask your own question. asked 2 years ago viewed 16388 times active 1 year ago Linked 59 #1025 - Error on rename of './database/#sql-2e0f_1254ba7' to './databa
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 http://stackoverflow.com/questions/4080611/1025-error-on-rename-of-database-sql-2e0f-1254ba7-to-database-table About Us Learn more about Stack Overflow the company Business Learn more about http://stackoverflow.com/questions/11649092/mysql-drop-foreign-key-error-152 hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up #1025 - Error foreign key on rename of './database/#sql-2e0f_1254ba7' to './database/table' (errno: 150) up vote 59 down vote favorite 13 So I am trying to add 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 drop foreign key 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 engine. mysql sql phpmyadmin innodb mysql-error-1025 share|improve this question edited Apr 30 '11 at 17:29 OMG Ponies 199k37360417 asked Nov 2 '10 at 17:55 Richard Knop 23.6k95284462 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 104 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,5031366131 answered Nov 2 '10 at 18:50 Ike Walker 33.6k95278 add a comment| up vote 18 down vote For those who are getting to this que
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 developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySQL Drop foreign key Error 152 up vote 9 down vote favorite 1 I am trying to drop a number of foreign keys using: ALTER TABLE `table` DROP FOREIGN KEY `fk_table_users1` , DROP FOREIGN KEY `fk_table_accounts1` , DROP FOREIGN KEY `fk_table_data1` ; but it returns the error: Error on rename of './db/table' to './db/#sql2-179c-288289' (errno: 152) I have run SHOW ENGINE INNODB STATUS which says: 120725 12:38:37 Error in dropping of a foreign key constraint of table db/table, in SQL command ALTER TABLE `table` DROP FOREIGN KEY `fk_table_users1` , DROP FOREIGN KEY `fk_table_accounts1` , DROP FOREIGN KEY `fk_table_data1` Cannot find a constraint with the given id fk_table_users1. SHOW CREATE TABLE 'table' output: CREATE TABLE `table` ( `id` int(11) NOT NULL auto_increment, `data_id` int(11) NOT NULL, `account_id` int(11) NOT NULL, `status` enum('pending','complete') NOT NULL default 'pending', `created_at` datetime NOT NULL, `created_by` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `fk_orders_users1` (`created_by`), KEY `fk_orders_data1` (`data_id`), KEY `fk_orders_accounts1` (`account_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 However when I look at the structure via phpmyadmin it lists the foreign key with the same name. Do I need to do something else before I can drop the foreign keys? mysql foreign-keys alter-table share|improve this question edited Jul 25 '12 at 12:14 asked Jul 25 '12 at 11:54 xylar 2,29153168 Please post the output of SHOW CREATE TABLE `table`;. –eggyal Jul 25 '12 at 12:09 @eggyal edited my post with the output –xylar Jul 25 '12 at 12:14 3 I don't see any foreign key constraints there... –eggyal Jul 25 '12 at 12:20 thanks for pointing that out. we use a migrations script and it looks like it didn't add the foreig