0
我在我的數據庫做了一些改變,從那以後,當我啓動它時,應用程序崩潰。我的代碼是:SQL數據庫「創建Tabe」
public static final String TABLE_TRANSACTION = "transaction";
public static final String COLUMN_TRANSACTION_ID = "TRANSACTION_ID";
public static final String COLUMN_TRANSACTION_DATE_CREATED = "TRANSACTION_DATE_CREATED";
public static final String COLUMN_TRANSACTION_ISOVERVIEW = "TRANSACTION_ISOVERVIEW";
public static final String COLUMN_TRANSACTION_NAME = "TRANSACTION_NAME";
public static final String COLUMN_TRANSACTION_DESCRIPTION = "TRANSACTION_DESCRIPTION";
public static final String COLUMN_TRANSACTION_TYPE = "TRANSACTION_TYPE";
public static final String COLUMN_TRANSACTION_AMOUNT = "TRANSACTION_AMOUNT";
public static final String COLUMN_TRANSACTION_REPEAT_CYCLE = "TRANSACTION_REPEAT_CYCLE";
public static final String COLUMN_TRANSACTION_REPEAT_DAY = "TRANSACTION_REPEAT_DAY";
public static final String COLUMN_TRANSACTION_REPEAT_ACTIVE = "TRANSACTION_REPEAT_ACTIVE";
private static final String DATABASE_CREATE_TRANSACTION = "create table "
+ TABLE_TRANSACTION + " ("
+ COLUMN_TRANSACTION_ID + " integer primary key autoincrement, "
+ COLUMN_TRANSACTION_DATE_CREATED + " VARCHAR(16), "
+ COLUMN_TRANSACTION_ISOVERVIEW + " VARCHAR(10), "
+ COLUMN_TRANSACTION_NAME + " VARCHAR(4096), "
+ COLUMN_TRANSACTION_DESCRIPTION + " VARCHAR(4096), "
+ COLUMN_TRANSACTION_TYPE + " INTEGER, "
+ COLUMN_TRANSACTION_AMOUNT + " FLOAT, "
+ COLUMN_TRANSACTION_REPEAT_CYCLE + " VARCHAR(20), "
+ COLUMN_TRANSACTION_REPEAT_DAY + " VARCHAR(20), "
+ COLUMN_TRANSACTION_REPEAT_ACTIVE + " VARCHAR(10));";
@Override
public void onCreate(SQLiteDatabase database) {
database.execSQL(DATABASE_CREATE_TRANSACTION);
}
,我得到這個錯誤:
Caused by: android.database.sqlite.SQLiteException: near "transaction": syntax error (code 1): , while compiling: create table transaction (TRANSACTION_ID integer primary key autoincrement, TRANSACTION_DATE_CREATED VARCHAR(16), TRANSACTION_ISOVERVIEW VARCHAR(10), TRANSACTION_NAME VARCHAR(4096), TRANSACTION_DESCRIPTION VARCHAR(4096), TRANSACTION_TYPE INTEGER, TRANSACTION_AMOUNT FLOAT, TRANSACTION_REPEAT_CYCLE VARCHAR(20), TRANSACTION_REPEAT_DAY VARCHAR(20), TRANSACTION_REPEAT_ACTIVE VARCHAR(10));
你能說得清的錯誤是什麼? Thx幫助
'TRANSACTION'是一個保留的關鍵字,在SQLite中:https://www.sqlite.org/lang_keywords.html –