0

我希望 KEYWORD 列应该包含 SQLite 数据库中的唯一值。如何修改以下查询来做到这一点?

查询如下:

  String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CONTACTS + "("
            + KEY_ID + " INTEGER PRIMARY KEY," + KEY_WORD + " TEXT "
            + KEY_KEYCODE + " TEXT" + ")";
4

2 回答 2

0

使用UNIQUE修饰符。

String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CONTACTS + "("
            + KEY_ID + " INTEGER PRIMARY KEY," + KEY_WORD + " TEXT UNIQUE "
            + KEY_KEYCODE + " TEXT" + ")";
于 2013-01-30T17:45:03.973 回答
0

使用唯一关键字:

String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CONTACTS + "("
        + KEY_ID + " INTEGER PRIMARY KEY," + KEY_WORD + " TEXT UNIQUE,"
        + KEY_KEYCODE + " TEXT" + ")";
于 2013-01-30T17:46:08.863 回答