当我的应用尝试创建sqlite表时,我收到语法错误。
这是创建表格的代码:
@Override
public void onCreate(SQLiteDatabase db) {
String SQL = pictureTable();
db.execSQL(SQL);
}
private String pictureTable() {
return "CREATE TABLE geophoto_db_pictures ( picid integer,"
+ "name character varying(50),"
+ "city character varying(20) NOT NULL DEFAULT 'Unknown',"
+ "zipcode character varying(20) NOT NULL DEFAULT 'Unknown',"
+ "country character varying(20) NOT NULL DEFAULT 'Unknown',"
+ "picdate datetime NOT NULL DEFAULT DATETIME('now'),"
+ "tags character varying(200)," + "image BLOB NOT NULL,"
+ "uploaded integer NOT NULL DEFAULT 0, PRIMARY KEY (picid))";
}
错误是: android.database.sqlite.SQLiteException:near"(":sytax error(code 1)
非常感谢任何帮助!
答案 0 :(得分:2)
默认值不能使用函数调用。
但是,您可以使用`CURRENT_TIMESTAMP'变量:
CREATE TABLE
...
picdate datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
...