我需要向现有表添加唯一字段索引。我做了这一行:
ALTER TABLE auth_user ADD UNIQUE INDEX (email);
表和字段已经存在。 错误是:
Query Error: near "UNIQUE": syntax error Unable to execute statement
我错过了什么?它对 SQLite3 有什么具体要求吗?
最佳答案
CREATE UNIQUE INDEX IF NOT EXISTS MyUniqueIndexName ON auth_user (email)
另外,阅读官方手册:
关于sql - 添加唯一索引。 SQLite3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7836561/