sqlite alter table add MULTIPLE columns in a single statement

前端 未结 4 594
南旧
南旧 2020-11-27 13:13

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          


        
4条回答
  •  难免孤独
    2020-11-27 13:53

    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.

提交回复
热议问题