这些是我在Java中声明的列名
public static final String TABLE_USER = "user_master";
public static final String ID = "id";
public static final String USER_ID = "user_id";
public static final String USER_FULLNAME = "user_fullname";
public static final String USER_MOBILE = "user_mobile";
public static final String USER_TYPE = "user_type";
public static final String USER_STATUS = "user_status";
这是生成的create table语句
String USER_MASTER = "CREATE TABLE user_master ( user_id INTEGER PRIMARY KEY, user_fullname TEXT, user_mobile TEXT, user_type TEXT, user_status TEXT ); ";
String USER_MASTER = " CREATE TABLE " + TABLE_USER + " ( "
+ ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ USER_ID + " INTEGER, "
+ USER_FULLNAME + " TEXT, "
+ USER_MOBILE + " TEXT, "
+ USER_TYPE + " TEXT, "
+ USER_STATUS + " TEXT ) ";
CREATE TABLE user_master(user_id INTEGER PRIMARY KEY, user_fullname TEXT, user_mobile TEXT, user_type TEXT, user_statusTEXT )
这里" user_statusTEXT" TEXT字会自动附加。
我只是不知道为什么?
我在SQLiteOpenHelper中尝试了两种方法来创建这个表,它仍然无法正常工作
答案 0 :(得分:1)
使用给定的代码很难调试。但是,列的数据类型规范在Sqlite CREATE TABLE
语句see docs中是可选的,因此您可以尝试删除所有TEXT数据类型并查看会发生什么。所以,
String USER_MASTER = " CREATE TABLE " + TABLE_USER + " ( "
+ ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ USER_ID + " INTEGER, "
+ USER_FULLNAME + " , "
+ USER_MOBILE + " , "
+ USER_TYPE + " , "
+ USER_STATUS + " ) ";