gpt4 book ai didi

java - SQL数据库 "create Tabe"

转载 作者:行者123 更新时间:2023-12-02 03:03:03 25 4
gpt4 key购买 nike

我对数据库做了一些更改,从那以后,每次启动应用程序时,它都会崩溃。我的代码是:

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) );

你能说一下错误在哪里吗?谢谢帮助

最佳答案

交易reserved keyword ,“不得用作表、索引、列、数据库、用户定义函数、排序规则、虚拟表模块或任何其他命名对象的名称”。您需要将表命名为其他名称。

关于java - SQL数据库 "create Tabe",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42179726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com