Mysql Alter Table Drop Foreign Key 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 #1025 - error on rename of (errno 150) policies of this site About Us Learn more about Stack Overflow the mysql drop foreign key errno 152 company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags mysql error 1025 errno 150 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 laravel drop foreign key 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
General Error: 1025 Error On Rename Of Laravel
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 &ndash
here for a quick overview of the site Help Center Detailed answers to any questions you might
Mysql List Foreign Keys
have Meta Discuss the workings and policies of this site About cannot drop index needed in a foreign key constraint Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting mysql drop foreign key if exists 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 http://stackoverflow.com/questions/11649092/mysql-drop-foreign-key-error-152 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Remove then add constraint mysql causes error on rename #1025 up vote 4 down vote favorite 1 Create table: CREATE TABLE `phppos_register_log` ( `register_log_id` int(10) NOT NULL AUTO_INCREMENT, `employee_id` int(10) NOT NULL, `shift_start` timestamp NOT NULL DEFAULT '0000-00-00 http://stackoverflow.com/questions/27952685/remove-then-add-constraint-mysql-causes-error-on-rename-1025 00:00:00', `shift_end` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `open_amount` decimal(23,10) NOT NULL, `close_amount` decimal(23,10) NOT NULL, `cash_sales_amount` decimal(23,10) NOT NULL, `deleted` int(1) NOT NULL DEFAULT '0', PRIMARY KEY (`register_log_id`), KEY `phppos_register_log_ibfk_1` (`employee_id`), CONSTRAINT `phppos_register_log_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `phppos_employees` (`person_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; SQL CODE to rename column: (This works on mysql 5.5 and 5.6 but one user is reporting an issue. (Exact version number 5.5.40) //this is where error is happening ALTER TABLE phppos_register_log DROP FOREIGN KEY phppos_register_log_ibfk_1; ALTER TABLE `phppos_register_log` CHANGE `employee_id` `employee_id_open` INT( 10 ) NOT NULL ; ALTER TABLE `phppos_register_log`ADD CONSTRAINT `phppos_register_log_ibfk_1` FOREIGN KEY (`employee_id_open`) REFERENCES `phppos_employees` (`person_id`); Is anything in mysql 5.5.40 that would cause this code to NOT work? ERROR reported: #1025 - Error on rename of './sole_phppos_144/phppos_register_log' to './sole_phppos_144/#sql2-6224-22975' (errno: 152) NOTE: I am renaming column so I drop the constraint, rename column, then add the constraint back. mysql share|improve this question edited Jan 14 '15 at 23:03 asked Jan 14 '15 at 21:2
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 https://bugs.mysql.com/bug.php?id=42416 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 1025 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, `NETAMOUNT` drop foreign key 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','2012/11','user2','password',80,40000,'M'); INSER
Updates: Status: Duplicate Impact on me: None Category:MySQL Server: Errors Severity:S3 (Non-critical) Version: 5.0.51a-3ubuntu5.4 (Ubuntu) OS:Linux Assigned to: View Add Comment Files Developer Edit Submission View Progress Log Contributions [28 Jan 2009 12:08] James b Description: see below I have seen http://bugs.mysql.com/bug.php?id=14347 but it doesn't seem to provide an answer. How to repeat: mysql> create database testing; Query OK, 1 row affected (0.00 sec) mysql> use testing; Database changed mysql> CREATE TABLE IF NOT EXISTS CollectionInfo ( -> CollectionName VARCHAR(255) NOT NULL PRIMARY KEY -> ) ENGINE=InnoDB; Query OK, 0 rows affected (0.01 sec) mysql> mysql> mysql> CREATE TABLE IF NOT EXISTS CollectionRequestHandler ( -> ID INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, -> CollectionName VARCHAR(255), -> CONSTRAINT `crh_cn` FOREIGN KEY (CollectionName) REFERENCES CollectionInfo(CollectionName) ON DELETE CASCADE -> ) ENGINE=InnoDB; Query OK, 0 rows affected (0.00 sec) mysql> mysql> ALTER TABLE CollectionInfo DROP FOREIGN KEY `crh_cn`; ERROR 1025 (HY000): Error on rename of './testing/CollectionInfo' to './testing/#sql2-1907-ed' (errno: 152) [28 Jan 2009 15:45] Valerii Kravchuk Thank you for a problem report. I had re-opened and verified that Bug #14347. This is a duplicate. Legal Policies Your Privacy Rights Terms of Use Contact Us Portions of this website are copyright © 2001, 2002 The PHP Group Page generated in 0.020 sec. using MySQL 5.7.12-enterprise-commercial-advanced-log Content reproduced on this site is the property of the respective copyright holders.It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party. © 2016, Oracle Corporation and/or its affiliates