无法在sqlite中创建表

时间:2014-02-21 09:54:03

标签: android sqlite

以下是我创建表格的查询,

String CREATE_OWNER_TABLE = "CREATE TABLE " + TABLE_OWNER + "(" + KEY_NAME + " TEXT NOT NULL," + KEY_CODE + " TEXT NOT NULL," + KEY_NUMBER + " TEXT NOT NULL," + KEY_SUM + "TEXT NOT NULL  );";
db.execSQL(CREATE_OWNER_TABLE);

我写了一个类似的查询来创建表所有者。但是有一个错误告诉我该表没有名为sum

的列

2 个答案:

答案 0 :(得分:4)

您在上一列的数据类型声明

之前缺少空格
KEY_SUM + "TEXT NOT NULL 

添加如下空格

String CREATE_OWNER_TABLE = "CREATE TABLE " + TABLE_OWNER + "(" + KEY_NAME + " TEXT NOT NULL," + KEY_CODE + " TEXT NOT NULL," + KEY_NUMBER + " TEXT NOT NULL," + KEY_SUM + " TEXT NOT NULL  );";
db.execSQL(CREATE_OWNER_TABLE);

答案 1 :(得分:1)

试试这个

 String CREATE_OWNER_TABLE = "CREATE TABLE " + TABLE_OWNER + "(" + KEY_NAME + " TEXT NOT NULL," + KEY_CODE + " TEXT NOT NULL," + KEY_NUMBER + " TEXT NOT NULL," + KEY_SUM + " TEXT NOT NULL);";