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

后端 未结 7 1370
星月不相逢
星月不相逢 2020-12-12 14:34

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)
         


        
7条回答
  •  粉色の甜心
    2020-12-12 15:26

    If you are trying to delete a column which is a FOREIGN KEY, you must find the correct name which is not the column name. Eg: If I am trying to delete the server field in the Alarms table which is a foreign key to the servers table.

    1. SHOW CREATE TABLE alarm; Look for the CONSTRAINT `server_id_refs_id_34554433` FORIEGN KEY (`server_id`) REFERENCES `server` (`id`) line.
    2. ALTER TABLE `alarm` DROP FOREIGN KEY `server_id_refs_id_34554433`;
    3. ALTER TABLE `alarm` DROP `server_id`

    This will delete the foreign key server from the Alarms table.

提交回复
热议问题