无法删除 AlaSQL 表中的行

Cannot delete rows in AlaSQL table

提问人:PhDJ 提问时间:11/15/2023 更新时间:11/16/2023 访问量:13

问:

我是 AlaSQL 的新手,一切正常,但是当我尝试删除行时遇到错误消息,我尝试以下操作:

          alasql.options.autocommit = true;
          alasql("CREATE localStorage DATABASE IF NOT EXISTS lsdb");
          alasql("ATTACH localStorage DATABASE lsdb AS db");
          alasql("CREATE TABLE IF NOT EXISTS db.people (Id INT,FirstName STRING,LastName STRING);");
          alasql("INSERT INTO db.people VALUES (1,'Peter','Peterson'), (2,'Eric','Ericson'), (3,'John','Johnson');");
          alasql("DELETE FROM db.people");
          alasql("SELECT * INTO HTML('#res',{headers:true}) FROM db.people;");

我收到此错误:

enter image description here

我错过了什么?

alasql

评论


答:

0赞 PhDJ 11/16/2023 #1

对代码进行了一些更改,这有效:

      alasql.options.autocommit = true;
      alasql("CREATE localStorage DATABASE IF NOT EXISTS lsdb");
      alasql("ATTACH localStorage DATABASE lsdb");
      alasql("USE lsdb");
      alasql("CREATE TABLE IF NOT EXISTS people (Id INT,FirstName STRING,LastName STRING)");
      alasql("INSERT INTO people VALUES (1,'Peter','Peterson'), (2,'Eric','Ericson'), (3,'John','Johnson')");
      alasql("DELETE FROM people");
      alasql("SELECT * INTO HTML('#res',{headers:true}) FROM people;");