Drop Foreign Key Error 1025
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 drop foreign key error on rename site About Us Learn more about Stack Overflow the company Business Learn more mysql drop foreign key error on rename about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss
Drop Foreign Key Postgres
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 unable to drop
Drop Table Foreign Key
the foreign key up vote 15 down vote favorite 2 I would like to drop the foreign key in my table but been into this error message mysql> alter table customers drop foreign key customerid; ERROR 1025 (HY000): Error on rename of '.\products\customers' to '.\products\#sql2-7ec-a3' (errno: 152) mysql> mysql foreign-keys foreign-key-relationship mysql-error-1025 share|improve this question edited May 17 '12 at 9:18 Fahim Parkar 15.8k2395193 mysql drop foreign key if exists asked May 17 '12 at 8:57 solomon 1171210 1 This may help you to understand stackoverflow.com/questions/160233/… –Imdad May 17 '12 at 9:04 @Imdad This link describes another error - (errno: 150) –Devart May 17 '12 at 9:17 Try this. Create new table (without foreign key constraint). copy the data to new table (using syntax INSERT INTO new_table SELECT * FROM old_table) Drop the old table –Imdad May 17 '12 at 9:22 Have you checked @Maksym Polshcha's answer? You have to use the foreign key's name not the column name. (it might be something like fk_customerid) –Imdad May 17 '12 at 9:24 check my answer and let me know if you still have problem... –Fahim Parkar May 17 '12 at 9:37 | show 1 more comment 4 Answers 4 active oldest votes up vote 5 down vote accepted To avoid getting this error while trying to drop a foreign key, use the constraint name rather than the column name of the foreign key. When I tried mysql> ALTER TABLE mytable DROP PRIMARY KEY; I got error as ERROR 1025 (HY000): Error on rename o
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
Drop Foreign Key Sql Server 2008
more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags drop foreign key constraint oracle Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like t sql drop foreign key constraint you, helping each other. Join them; it only takes a minute: Sign up Error when trying to DELETE foreign key: “ERROR 1025 (HY000):” up vote 7 down vote favorite I am running into some trouble trying to delete http://stackoverflow.com/questions/10632587/unable-to-drop-the-foreign-key a foreign key. Could someone please help? Here’s my SHOW CREATE TABLE catgroup: | catgroup | CREATE TABLE `catgroup` ( `catgroupid` int(11) NOT NULL AUTO_INCREMENT, `category_id` int(11) NOT NULL, `group_id` int(11) NOT NULL, PRIMARY KEY (`catgroupid`), KEY `category_id` (`category_id`), KEY `group_id` (`group_id`), CONSTRAINT `catgroup_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `cat s` (`cid`) ON UPDATE CASCADE, CONSTRAINT `catgroup_ibfk_2` FOREIGN KEY (`group_id`) REFERENCES `groups d`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8 | This is how I am http://stackoverflow.com/questions/7062910/error-when-trying-to-delete-foreign-key-error-1025-hy000 trying to drop the foreign key: ALTER TABLE catgroup DROP FOREIGN KEY group_id_ibfk_2; And here’s the error message: ERROR 1025 (HY000): Error on rename of '.\asset_base\catgroup' to '.\asset_base\ sql2-16b4-4' (errno: 152) What am I doing wrong? mysql foreign-keys share|improve this question edited May 22 '13 at 15:56 Federico Razzoli 1,594615 asked Aug 15 '11 at 8:23 Henkka 3623817 add a comment| 3 Answers 3 active oldest votes up vote 6 down vote You have the wrong name of the foreign key. Try catgroup_ibfk_2 instead. The strange error message is already reported as a bug in MySQL. share|improve this answer answered Aug 15 '11 at 8:26 Emil Vikström 59.2k1183130 add a comment| up vote 2 down vote Ancient post, but FWIW I just discovered that the foreign key name is case sensitive... share|improve this answer answered May 22 '13 at 15:46 Brian 591 add a comment| up vote 0 down vote [admin@gold ~]$ perror 152 MySQL error code 152: Cannot delete a parent row Altering indexes/constraints on an InnoDB table involves dropping the table and rebuilding it. You probably need to remove the constraint on the other table pointing to these parent rows before you can do that. share|improve this answer answered Aug 15 '11 at 8:27 Dan Grossman 37.8k87381 add a comment| Your Answer draft saved draft discarded Sign up or log in S
Verified Impact on me: None Category:MySQL Server: Parser Severity:S2 (Serious) Version:5.0.15, 5.0.74, 5.1.30, https://bugs.mysql.com/bug.php?id=14347 6.0.9 OS:Linux (Linux Suse 10, Windows) Assigned to: Tags: foreign key, innodb Triage: Triaged: D5 (Feature request) View Add Comment Files Developer Edit Submission View Progress Log Contributions [26 Oct 2005 18:53] Vadim Tkachenko Description: When I try ALTER TABLE ORDERS DROP FOREIGN KEY CUSTOMERID; I got: ERROR foreign key 1025 (HY000): Error on rename of './TESTDB/ORDERS' to './TESTDB/#sql2-3b5b-8' (errno: 152) But I only want to remove FOREIGN KEY and I don't delete any rows. How to repeat: DROP TABLE IF EXISTS `ORDERS`; CREATE TABLE `ORDERS` ( `ORDERID` int(11) NOT NULL auto_increment, `ORDERDATE` date NOT NULL, `CUSTOMERID` int(11) default drop foreign key NULL, `NETAMOUNT` decimal(12,2) NOT NULL, `TAX` decimal(12,2) NOT NULL, `TOTALAMOUNT` decimal(12,2) NOT NULL, PRIMARY KEY (`ORDERID`), KEY `IX_ORDER_CUSTID` (`CUSTOMERID`), CONSTRAINT `FK_CUSTOMERID` FOREIGN KEY (`CUSTOMERID`) REFERENCES `CUSTOMERS` (`CUSTOMERID`) ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; DROP TABLE IF EXISTS `CUSTOMERS`; CREATE TABLE `CUSTOMERS` ( `CUSTOMERID` int(11) NOT NULL auto_increment, `FIRSTNAME` varchar(50) NOT NULL, `LASTNAME` varchar(50) NOT NULL, `ADDRESS1` varchar(50) NOT NULL, `ADDRESS2` varchar(50) default NULL, `CITY` varchar(50) NOT NULL, `STATE` varchar(50) default NULL, `ZIP` int(11) default NULL, `COUNTRY` varchar(50) NOT NULL, `REGION` tinyint(4) NOT NULL, `EMAIL` varchar(50) default NULL, `PHONE` varchar(50) default NULL, `CREDITCARDTYPE` int(11) NOT NULL, `CREDITCARD` varchar(50) NOT NULL, `CREDITCARDEXPIRATION` varchar(50) NOT NULL, `USERNAME` varchar(50) NOT NULL, `PASSWORD` varchar(50) NOT NULL, `AGE` tinyint(4) default NULL, `INCOME` int(11) default NULL, `GENDER` varchar(1) default NULL, PRIMARY KEY (`CUSTOMERID`), UNIQUE KEY `IX_CUST_USERNAME` (`USERNAME`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `CUSTOMERS` VALUES (1,'VKUUXF','ITHOMQJNYX','4608499546 Dell Way','','QSDPAGD','SD',24101,'US',1,'ITHOMQJNYX@dell.com',' 4608499546',1,'1979279217775911','2012/03','user1','passwor