在 SQLite 中创建 table 时出现语法错误

Syntax error when creating table in SQLite

我的应用程序尝试创建 sqlite 时出现语法错误 table。

这是创建 table:

的代码
@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:靠近“(”:语法错误(代码 1)

非常感谢任何帮助!

默认值不能使用函数调用。

但是,您可以使用“CURRENT_TIMESTAMP”变量:

CREATE TABLE
    ...
    picdate datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
    ...