gpt4 book ai didi

sqlite - 创建表语法错误SQLite

转载 作者:行者123 更新时间:2023-12-03 08:22:54 24 4
gpt4 key购买 nike

在SQLite中创建四行表时出现语法错误,但不知道为什么。这是我的代码。

 private static final String TABLE_PRIMERO = "jugadors";

// Jugadors Table Columns names
private static final String KEY_ID = "id";
private static final String KEY_NAME = "name";
private static final String KEY_ALTURA = "altura";
private static final String KEY_PARTIDO = "partido";

int oldVersion=1;

public DatabaseHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

// Creating Tables
@Override
public void onCreate(SQLiteDatabase db) {

String CREATE_JUGADORS_TABLE1 = "CREATE TABLE_PRIMERO " + TABLE_PRIMERO + "("
+ KEY_ID + " INTEGER PRIMARY KEY,"
+ KEY_NAME + " TEXT,"
+ KEY_ALTURA + " TEXT,"
+ KEY_PARTIDO + " TEXT"
+ ")";
db.execSQL(CREATE_JUGADORS_TABLE1);


}

//Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_PRIMERO);

// Create tables again
onCreate(db);
}

我不知道我在做什么错。

提前致谢。

最佳答案

String CREATE_JUGADORS_TABLE1 = "CREATE TABLE_PRIMERO " + TABLE_PRIMERO + "("
+ KEY_ID + " INTEGER PRIMARY KEY,"
+ KEY_NAME + " TEXT,"
+ KEY_ALTURA + " TEXT,"
+ KEY_PARTIDO + " TEXT"
+ ")";

这应该像
String CREATE_JUGADORS_TABLE1 = "CREATE TABLE " + TABLE_PRIMERO + "("
+ KEY_ID + " INTEGER PRIMARY KEY,"
+ KEY_NAME + " TEXT,"
+ KEY_ALTURA + " TEXT,"
+ KEY_PARTIDO + " TEXT"
+ ")";
TABLE是具有特定含义的关键字。

关于sqlite - 创建表语法错误SQLite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21907295/

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