public static final String DB_NAME = "task_management";
public static final int DB_VERSION = 1;
public static final String EMPLOYEE_TABLE = "employee";
public static final String ID_FIELD = "_id";
public static final String NAME_FIELD = "name";
public static final String TIME_DATE = "time_date";
public static final String EMPLOYEE_TABLE_SQL = "CREATE TABLE"
+ EMPLOYEE_TABLE + "(" + ID_FIELD + "INTEGER PRIMARY KEY,"
+ NAME_FIELD + "name," + TIME_DATE + "time_date,)";
我的数据库有什么问题?
我的日志猫显示
“TABLEemployee”:语法错误。
如何解决?
答案 0 :(得分:0)
在...TABLE"
和EMPLOYEE_TABLE
...
像:
EMPLOYEE_TABLE_SQL = "CREATE TABLE " + EMPLOYEE_TABLE...
^
add space here
答案 1 :(得分:0)
public static final String EMPLOYEE_TABLE_SQL =
"CREATE TABLE " + EMPLOYEE_TABLE
+ "(" + ID_FIELD + "integer primary key autoincrement,"
+ NAME_FIELD + "string," + TIME_DATE + "datetime)"
+ ");";
这个怎么样?
答案 2 :(得分:0)
您的员工表sql不正确。除了语法错误(缺少空格,缺少结束分号)之外,还需要为TIME_DATE列定义数据类型。
顺便说一下,我实际上已经在SQLite数据库上执行这个sql语句了,但它确实有效。
试试这个:
public static final String EMPLOYEE_TABLE_SQL = "CREATE TABLE "
+ EMPLOYEE_TABLE + " (" + ID_FIELD + " INTEGER PRIMARY KEY, "
+ NAME_FIELD + " TEXT, " + TIME_DATE + " DATETIME);";