我希望 KEYWORD 列应该包含 SQLite 数据库中的唯一值。如何修改以下查询来做到这一点?
查询如下:
String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CONTACTS + "("
+ KEY_ID + " INTEGER PRIMARY KEY," + KEY_WORD + " TEXT "
+ KEY_KEYCODE + " TEXT" + ")";
我希望 KEYWORD 列应该包含 SQLite 数据库中的唯一值。如何修改以下查询来做到这一点?
查询如下:
String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CONTACTS + "("
+ KEY_ID + " INTEGER PRIMARY KEY," + KEY_WORD + " TEXT "
+ KEY_KEYCODE + " TEXT" + ")";
使用UNIQUE
修饰符。
String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CONTACTS + "("
+ KEY_ID + " INTEGER PRIMARY KEY," + KEY_WORD + " TEXT UNIQUE "
+ KEY_KEYCODE + " TEXT" + ")";
使用唯一关键字:
String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CONTACTS + "("
+ KEY_ID + " INTEGER PRIMARY KEY," + KEY_WORD + " TEXT UNIQUE,"
+ KEY_KEYCODE + " TEXT" + ")";