0

my question is asking how I can create a column in a table that is pre made. I am using better-sqlite3 and am hoping to understand how to alter tables with better-sqlite3. My current code that I have tried is sql.prepare("ALTER TABLE user ADD COLUMN order INTEGER;").run() Im not sure why it doesn't work and there is no error message provided. However, what I have tried to do is use DB browser for sqlite but have had no success in altering the table. Does anyone know how to do this in node.js? I think the reason may be how im preparing the table but I would not be sure about this.

king
  • 127
  • 1
  • 7
  • 4
    I haven't tested it, but `order` might be a reserved keyword? – Glorfindel Apr 26 '20 at 20:04
  • 1
    `order` is a reserved word in every SQL-based DBMS. It's used in the `ORDER BY` clause for a `SELECT`. Use a different column name such as `ORDERID` or `ORDERNO` instead. – Ken White Apr 26 '20 at 20:07

0 Answers0