I used the same command syntax above as in Mysql and would like set a unique key for the tables’s filed on Android Device environment, however, the error prompted in LogCat:
03-23 16:16:45.580: E/Database(657): Failure 1 (near “UNIQUE”: syntax
error) on 0x2c0240 when preparing ‘ALTER TABLEgameADD
UNIQUE(name);’.
Checking the SQLite’s doc, it seems that SQLite does not use this way for setting a unique key. Does anyboy know to do it ? Thanks for response inadvance !
sqlite support alter in another way.
You can try the following:
create unique index unique_name on game(name);If you want to create a constraint for two or more columns at one time:
create unique index unique_name on game(name1,name2,mame3);