Drop Foreign Key Mysql Error
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 mysql drop foreign key error on rename site About Us Learn more about Stack Overflow the company Business Learn
Drop Foreign Key Mysql Example
more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x
Drop Foreign Key Constraint Mysql
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 unable
Mysql Drop Foreign Key If Exists
to drop 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 mysql drop table foreign key Parkar 15.8k2395193 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 (H
Verified Impact on me: None Category:MySQL Server: Parser Severity:S2 (Serious) Version:5.0.15, 5.0.74, 5.1.30, mysql drop foreign key errno 152 6.0.9 OS:Linux (Linux Suse 10, Windows) Assigned to: Tags: foreign mysql drop foreign key index key, innodb Triage: Triaged: D5 (Feature request) View Add Comment Files Developer Edit Submission View mysql drop foreign key without name Progress Log Contributions [26 Oct 2005 18:53] Vadim Tkachenko Description: When I try ALTER TABLE ORDERS DROP FOREIGN KEY CUSTOMERID; I got: ERROR 1025 http://stackoverflow.com/questions/10632587/unable-to-drop-the-foreign-key (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 NULL, https://bugs.mysql.com/bug.php?id=14347 `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','password',55,100000,'M'),(2,'HQNMZH','UNUKXHJVXB','5119315633 Dell Way','','YNCE RXJ','AZ',11802,'US',1,'UNUKXHJVXB@dell.com','5119315633',1,'3144519586581737
log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions http://dba.stackexchange.com/questions/109390/error-while-deleting-a-foreign-key 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 Database Administrators Questions Tags Users Badges Unanswered Ask Question _ Database Administrators Stack Exchange is a question and answer site for database professionals foreign key 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 The best answers are voted up and rise to the top Error while deleting a foreign key up vote drop foreign key 0 down vote favorite I can't delete foreign key in MySQL, I get this error message: ERROR 1025 (HY000): Error on rename of './database/table_name' to './hp/#sql2-4b1-26' (errno: 152) My system is Ubuntu 14.4 lts mysql foreign-key linux share|improve this question edited Aug 7 '15 at 15:22 mustaccio 4,82011326 asked Aug 7 '15 at 15:15 Mohaned Sec 1 2 Edit your question with: the SHOW CREATE TABLE name; output and the exact statement that produces this error. –ypercubeᵀᴹ Aug 7 '15 at 15:21 1 Does your question get answered by [this][1]? [1]: stackoverflow.com/questions/160233/… –mysql_user Aug 7 '15 at 16:19 1 or any of these: forums.mysql.com/read.php?22,602534 (Error #1025 150/152) forums.mysql.com/read.php?10,516275 (SQLSTATE[HY000]: General error: 1025 Error on rename of..) forums.mysql.com/read.php?10,424702 (New database seems to be messing with old.) forums.mysql.com/read.php?20,425100 (Issue w/ multiple ALTER TABLE statements in a single transaction) –Rick James Aug 7 '15 at 16:20 1 or forums.mysql.com/read.php?10,267723 (Problem dropping foreign keys from multiple tables in a single multi-statement) forum