阅读SQLiteDatabase.execSQL的文档时,我有点惊讶。它说“不支持用分号分隔的多个语句。”
之前阅读它时我不会感到惊讶,但我的应用程序使用了如下命令:
private static final String CREATE_TABLE =
"create table "
+ TABLENAME + "("
+ COLUMN_ID + " integer primary key autoincrement, "
+ COLUMN_CODE + " text not null,"
+ COLUMN_NAME + " text not null,"
+ COLUMN_STOCK + " integer,"
+ COLUMN_PRICE + " real,"
+ COLUMN_LISTPRICE + " real"
+ ");"
+ "create index "
+ TABLENAME + "_idx on " + TABLENAME
+ "(" + COLUMN_NAME + ", "
+ COLUMN_STOCK + ", "
+ COLUMN_PRICE
+ ");";
...
database.execSQL(CREATE_TABLE);
我没有观察到任何错误或异常(或者我没有注意到)。这是否意味着我的语句中的索引没有创建?还是文档有误?