How to drop column if and only if it exists in postgres in 9+ version

i am trying to drop a column from a table.

what could be the best practices to check if column exists or not.

i went through the documentation https://www.postgresql.org/docs/9.2/static/sql-altertable.html but didnt find any example how to do it.

Even found this in stackoverflow How to check if a column exists in SQL Server table, but seems not so relevant


ALTER TABLE tableName DROP COLUMN IF EXISTS columnName;

链接地址: http://www.djcxy.com/p/94410.html

上一篇: SQL插入取决于列是否存在

下一篇: 如何删除列当且仅当它存在于9+版本的postgres中