How to add column if not exists on PostgreSQL?

Question is simple. How to add column x to table y, but only when x column doesn’t exist ? I found only solution here how to check if column exists.

SELECT column_name 
FROM information_schema.columns 
WHERE table_name="x" and column_name="y";

11 Answers
11

Leave a Comment