mysql-error-1025

Problem adding Foreign Key using Alter Table with existing MYSQL Database - can't add it! Help!

廉价感情. 提交于 2019-11-28 11:14:27
I have a production database where I have renamed several column's that are foreign keys. Obviously mysql makes this a real pain to do in my experience. My solution was to drop all the indexes and foreign keys, rename the id columns, and then re-add the indexes and foreign keys. This works great on mysql 5.1 on windows for the development database. I went to run my migration script on my debian server, which is also using mysql 5.1, and it gives the following error: mysql> ALTER TABLE `company_to_module` -> ADD CONSTRAINT `FK82977604FE40A062` FOREIGN KEY (`company_id`) REFERENCES `company` (

Changing MySQL primary key when foreign key contraints exist

空扰寡人 提交于 2019-11-28 07:27:08
问题 I have two already-existing tables which look (in part) roughly like this: CREATE TABLE parent ( old_pk CHAR(8) NOT NULL PRIMARY KEY ) ENGINE=InnoDB; CREATE TABLE child ( parent_key CHAR(8), FOREIGN KEY (parent_key) REFERENCES parent(old_pk) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB; I want to add a new auto-incrementing integer id column to parent and use it as the primary key instead, while still keeping old_pk as a unique key and allowing other tables like child to reference it

#1025 - Error on rename of './database/#sql-2e0f_1254ba7' to './database/table' (errno: 150)

混江龙づ霸主 提交于 2019-11-27 19:50:38
问题 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 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

Renaming foreign-key columns in MySQL

谁都会走 提交于 2019-11-27 04:35:06
We're trying to rename a column in MySQL (5.1.31, InnoDB) that is a foreign key to another table. At first, we tried to use Django-South, but came up against a known issue: http://south.aeracode.org/ticket/243 OperationalError: (1025, "Error on rename of './xxx/#sql-bf_4d' to './xxx/cave_event' (errno: 150)") AND Error on rename of './xxx/#sql-bf_4b' to './xxx/cave_event' (errno: 150) This error 150 definitely pertains to foreign key constraints. See e.g. What does mysql error 1025 (HY000): Error on rename of './foo' (errorno: 150) mean? http://www.xaprb.com/blog/2006/08/22/mysqls-error-1025

MySQL Removing Some Foreign keys

一曲冷凌霜 提交于 2019-11-26 21:24:26
I have a table whose primary key is used in several other tables and has several foreign keys to other tables. CREATE TABLE location ( locationID INT NOT NULL AUTO_INCREMENT PRIMARY KEY ... ) ENGINE = InnoDB; CREATE TABLE assignment ( assignmentID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, locationID INT NOT NULL, FOREIGN KEY locationIDX (locationID) REFERENCES location (locationID) ... ) ENGINE = InnoDB; CREATE TABLE assignmentStuff ( ... assignmentID INT NOT NULL, FOREIGN KEY assignmentIDX (assignmentID) REFERENCES assignment (assignmentID) ) ENGINE = InnoDB; The problem is that when I'm

Error renaming a column in MySQL

别说谁变了你拦得住时间么 提交于 2019-11-26 18:09:29
How do I rename a column in table xyz ? The columns are: Manufacurerid, name, status, AI, PK, int I want to rename to manufacturerid I tried using PHPMyAdmin panel, but I get this error: MySQL said: Documentation #1025 - Error on rename of '.\shopping\#sql-c98_26' to '.\shopping\tblmanufacturer' (errno: 150) Matt Diamond Lone Ranger is very close... in fact, you also need to specify the datatype of the renamed column. For example: ALTER TABLE `xyz` CHANGE `manufacurerid` `manufacturerid` INT; Remember : Replace INT with whatever your column data type is (REQUIRED) Tilde/ Backtick (`) is

What does mysql error 1025 (HY000): Error on rename of './foo' (errorno: 150) mean?

不羁岁月 提交于 2019-11-26 12:42:54
I tried this in mysql: 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? 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

Renaming foreign-key columns in MySQL

风流意气都作罢 提交于 2019-11-26 11:15:46
问题 We\'re trying to rename a column in MySQL (5.1.31, InnoDB) that is a foreign key to another table. At first, we tried to use Django-South, but came up against a known issue: http://south.aeracode.org/ticket/243 OperationalError: (1025, \"Error on rename of \'./xxx/#sql-bf_4d\' to \'./xxx/cave_event\' (errno: 150)\") AND Error on rename of \'./xxx/#sql-bf_4b\' to \'./xxx/cave_event\' (errno: 150) This error 150 definitely pertains to foreign key constraints. See e.g. What does mysql error 1025

MySQL Removing Some Foreign keys

本小妞迷上赌 提交于 2019-11-26 07:55:13
问题 I have a table whose primary key is used in several other tables and has several foreign keys to other tables. CREATE TABLE location ( locationID INT NOT NULL AUTO_INCREMENT PRIMARY KEY ... ) ENGINE = InnoDB; CREATE TABLE assignment ( assignmentID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, locationID INT NOT NULL, FOREIGN KEY locationIDX (locationID) REFERENCES location (locationID) ... ) ENGINE = InnoDB; CREATE TABLE assignmentStuff ( ... assignmentID INT NOT NULL, FOREIGN KEY assignmentIDX

Error renaming a column in MySQL

时光怂恿深爱的人放手 提交于 2019-11-26 06:12:08
问题 How do I rename a column in table xyz ? The columns are: Manufacurerid, name, status, AI, PK, int I want to rename to manufacturerid I tried using PHPMyAdmin panel, but I get this error: MySQL said: Documentation #1025 - Error on rename of \'.\\shopping\\#sql-c98_26\' to \'.\\shopping\\tblmanufacturer\' (errno: 150) 回答1: Lone Ranger is very close... in fact, you also need to specify the datatype of the renamed column. For example: ALTER TABLE `xyz` CHANGE `manufacurerid` `manufacturerid` INT;