我有下一个查询:
Cursor cursor = ES09SQLiteHelper.getDatabase()
.query(CompanyDomain.TABLE_NAME,
allColumns,
CompanyDomain.ADDRESS + " LIKE ? AND "
+ CompanyDomain.NAME + " LIKE ?",
new String[] { Cities.TATARSTAN + city + "%",
"%" + query + "%" }, null, null, null);
这意味着SELECT * FROM companies WHERE address LIKE city% AND name LIKE %query%;
如何为此创建索引?我做了以下事情:
database.execSQL("CREATE INDEX company_address_index ON "
+ CompanyDomain.TABLE_NAME + "(" + CompanyDomain.ADDRESS
+ " COLLATE NOCASE)");
但我的索引应该包含一个字段。我怎么能这样做?
答案 0 :(得分:2)
database.execSQL("CREATE INDEX company_address_index ON "
+ CompanyDomain.TABLE_NAME + "(name, address
+ " COLLATE NOCASE)");
或者在普通的SQLite中:
CREATE INDEX [name-of-index] ON [table-name]([column1],[column2], ...)