gpt4 book ai didi

sqlite - 尝试向SQLite表中添加UNIQUE INDEX时为什么出现“索引列不是唯一的”错误?

转载 作者:行者123 更新时间:2023-12-03 18:36:48 28 4
gpt4 key购买 nike

尝试使用以下语法创建唯一索引时:

CREATE UNIQUE INDEX Table_Index ON Table (CharColumn, IntColumn)

为什么会收到错误消息:

indexed columns are not unique

最佳答案

由于索引列不是唯一的,即存在一些重复的记录,因此出现错误“索引列不是唯一的”。

使用类似这样的查询来找出哪些记录:

SELECT CharColumn,
IntColumn,
COUNT(*) AS Count
FROM MyTable
GROUP BY CharColumn,
IntColumn
HAVING Count > 1

关于sqlite - 尝试向SQLite表中添加UNIQUE INDEX时为什么出现“索引列不是唯一的”错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20576326/

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