ADD COLUMN IF NOT EXISTS does not recognize "IF NOT EXIST". How do I add a column to an existing delta table with SQL if the column does not already exist?

Christine
Contributor II

How do I add a column to an existing delta table with SQL if the column does not already exist?

I am using the following code:

<%sql

ALTER TABLE table_name ADD COLUMN IF NOT EXISTS column_name type; >

but it prints the error:

<[PARSE_SYNTAX_ERROR] Syntax error at or near 'EXISTS'(line 1, pos 41)

== SQL ==

ALTER TABLE table_name ADD COLUMN IF NOT EXISTS column_name type

-----------------------------------------^^^>