0

Here's a screenshot of my commands and db. I'm working in Sqlite3. SQLITE 3 commands

Everything seems fine and I can't see any issues with my command, but I still get an error. Any advice?

Meysam Asadi
  • 6,438
  • 3
  • 7
  • 17
BrianZhang
  • 153
  • 1
  • 8
  • 2
    SQLite doesn't support ALTER TABLE ALTER COLUMN: https://www.sqlite.org/lang_altertable.html. – Gordon Linoff Jul 25 '21 at 16:17
  • You can't add unique constraints to existing tables in SQLite, though you can add a unique index for equivalent functionality... 2nd answer here: https://stackoverflow.com/questions/15497985/how-to-add-unique-constraint-to-existing-table-in-sqlite-ios – MatBailie Jul 25 '21 at 16:18

1 Answers1

0

Use two command lines Define the first line of the column and the second line create a unique constraint for it.

ALTER TABLE accounts ADD username VARCHAR(30);
CREATE UNIQUE INDEX accounts_unique_index ON accounts (username);
Meysam Asadi
  • 6,438
  • 3
  • 7
  • 17