Is it possible to alter table add MULTIPLE columns in a single statement in sqlite? The following would not work.
alter table test add column mycolumn1 text, add column mycolumn2 text;
No, you have to add them one at a time. See the syntax diagram at the top of SQLite's ALTER TABLE documentation:
There's no loop in the ADD
branch so no repetition is allowed.
The only thing so far possible that I use is
BEGIN TRANSACTION;
ALTER TABLE tblName ADD ColumnNameA TEXT DEFAULT '';
ALTER TABLE tblName ADD ColumnNameB TEXT DEFAULT '';
ALTER TABLE tblName ADD ColumnNameC TEXT DEFAULT '';
COMMIT
Note that there are ; on purpose to make the query be read as multiple lines.
Then I run this query and get multiple columns added in on run... So no not in one line, but yes in one query its possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With