【问题标题】:Add unique index. SQLite3添加唯一索引。 SQLite3
【发布时间】:2011-10-20 13:21:03
【问题描述】:

我需要为现有表添加唯一字段索引。我做了这一行:

ALTER TABLE auth_user ADD UNIQUE INDEX (email);

表和字段已经存在。 错误是:

查询错误:“UNIQUE”附近:语法错误无法执行语句

我错过了什么?对 SQLite3 有什么特殊要求吗?

【问题讨论】:

    标签: sql sqlite ddl unique-index


    【解决方案1】:
    CREATE UNIQUE INDEX IF NOT EXISTS MyUniqueIndexName ON auth_user (email)
    

    另外,请阅读官方手册:

    http://www.sqlite.org/lang_createindex.html

    【讨论】:

      猜你喜欢
      • 2017-01-11
      • 2020-12-27
      • 1970-01-01
      • 1970-01-01
      • 2015-07-01
      • 2018-02-20
      • 2013-06-11
      • 1970-01-01
      • 2013-05-31
      相关资源
      最近更新 更多