Android Sqlite数据库列在Create table脚本中定义但不在表上创建

时间:2013-09-10 11:48:27

标签: android sqlite

我有一个下表脚本:

"CREATE TABLE " + TABLE_XXX + "("
                    + XXX_ID + " INTEGER PRIMARY KEY,"
                    + XXX_ITEM_NO + "TEXT,"
                    + XXX_DETAILS +"TEXT,"
                    + XXX_EXP_DATE + "TEXT,"
                    + XXX_IS_OK +"INTEGER, "
                    + XXX_CODE + "TEXT"
                    + ")"; 

但是当我要插入数据以获取错误时, TABLE_XXX没有名为XXX_IS_OK的列

如何克服它。 谢谢!

2 个答案:

答案 0 :(得分:1)

您的陈述中缺少空格。

+ XXX_IS_OK +"INTEGER, "

应该是:

+ XXX_IS_OK +" INTEGER, "

答案 1 :(得分:1)

您需要在代码上添加一些空格。在引号之前。

"CREATE TABLE " + TABLE_XXX + "("   
+ XXX_ID + " INTEGER PRIMARY KEY, "   
+ XXX_ITEM_NO + " TEXT, "     
+ XXX_DETAILS +" TEXT, "   
+ XXX_EXP_DATE + " TEXT, "   
+ XXX_IS_OK + " INTEGER, "
+ XXX_CODE + " TEXT "   
+ ")";