gpt4 book ai didi

php - 如何使多个列在同一个表中唯一

转载 作者:行者123 更新时间:2023-11-29 03:16:31 25 4
gpt4 key购买 nike

ALTER TABLE  `registered` CHANGE  `Email_ID` UNIQUE KEY ( Email_ID) ) ;

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNIQUE KEY ( Email_ID )' at line 1

最佳答案

基本查询应该是这样的:

ALTER TABLE `test1`
ADD UNIQUE KEY (`id`),
ADD UNIQUE KEY `code` (`code`),
ADD KEY `other` (`other`);

用于单独的唯一键。

组合键如下所示:

ALTER TABLE `test2`
ADD UNIQUE KEY `id_code` (`id`, `code`),
ADD KEY `other` (`other`);

(注:MySQL代码由phpmyadmin生成)

关于php - 如何使多个列在同一个表中唯一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55346760/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com