2011-07-19 78 views
3

我想将“InputOutputConfigurationServerAccountId”重命名为“CompositeKey”。我如何通过SQL来做到这一点?我的表定义的MySQL:更改唯一的密钥名称?

部分:

UNIQUE KEY `InputOutputConfigurationServerAccountId` (`InputOutputConfigurationServerAccountId`,`Identifier`,`TimeStampReceived`) 

该表已在生产。我正试图改变桌子。

+1

可能的重复http://stackoverflow.com/questions/1463363/how-do-i-rename-an-index-in-mysql –

回答

7

是的,费米是对的。它会这样做:

ALTER TABLE `test`.`UniqueKeys` 

DROP INDEX `InputOutputConfigurationServerAccountId`, 
ADD UNIQUE INDEX `CompositeKey` (`InputOutputConfigurationServerAccountId`, 
`Identifier`,`TimeStampReceived`) ; 
1

MySQL's ALTER syntax当前不支持重命名密钥。您将不得不创建一个新的组合键并放弃旧的组合键。