Support for IF EXISTS
(1) By alain (abdekker) on 2022-02-18 23:33:35 [link] [source]
Fairly new to SQLite. The following queries works: DROP TABLE IF EXISTS MyTable; ALTER TABLE MyTable DROP COLUMN MyField; But this fails with a syntax error: ALTER TABLE MyTable DROP COLUMN IF EXISTS MyField; I note that the documentation on DROP TABLE (https://sqlite.org/lang_droptable.html) does mention "IF EXISTS", while the documentation for ALTER TABLE (https://sqlite.org/lang_altertable.html) does not. I assume this is a clue that IF EXISTS is not supported for the ALTER TABLE statement. Is my observation correct? And are there plans to support "IS EXISTS" and "IF NOT EXISTS" for adding / dropping columns in a future release of SQLite?
(2) By Stephan Beal (stephan) on 2022-02-18 23:36:42 in reply to 1 [link] [source]
And are there plans to support "IS EXISTS" and "IF NOT EXISTS" for adding / dropping columns in a future release of SQLite?
(3) By alain (abdekker) on 2022-02-18 23:46:26 in reply to 2 [source]
Thanks. That thread covers the same subject and is a better place for discussion of this.
From that thread I can note that the observation "SQLite does not currently support 'ALTER TABLE ... ADD COLUMN IF NOT EXISTS...' or 'ALTER TABLE ... DROP COLUMN IF EXISTS ...'" is correct.