我正在学习如何在Flutter应用程序中升级数据库,尽管很简单,但是执行INSERT时出现此错误:
E / SQLiteLog(9107):(1)表的tempsettings没有名为user的列 I / flutter(9107):DatabaseException(表临时设置没有列 命名用户(代码1 SQLITE_ERROR):,而在编译时:INSERT INTO tempsettings('id','user','company','url')SELECT'id','user', 'company','url'FROM settings)E / SQLiteLog(9107):(1)否这样 列:用户I / flutter(9107):DatabaseException(无此类列:user (代码1 SQLITE_ERROR):,而在编译时:INSERT INTO settings('id', '用户','公司','URL','主题')SELECT ID,用户,公司,URL,1 来自临时设置)
await db
.execute("CREATE TABLE tempsettings("
"'id' INTEGER "
"'user' TEXT,"
"'company' TEXT,"
"'url' TEXT)")
.catchError((error) => print(error.toString()));
await db.execute(
"INSERT INTO tempsettings('id', 'user', 'company', 'url') SELECT 'id', 'user', 'company', 'url' FROM settings")
.catchError((error) => print(error.toString()));
有人可以帮助我进行此插入吗?
谢谢。
答案 0 :(得分:0)
创建ID列后,您缺少逗号
await db.execute("CREATE TABLE tempsettings("
"id INTEGER ", //this comma was missing
"user TEXT,"
"company TEXT,"
"url TEXT)")
.catchError((error) => print(error.toString()));