How do I add multiple columns in one query statement in PostgreSQL using pgadmin3?
2 Answers
Try this :
ALTER TABLE table ADD COLUMN col1 int, ADD COLUMN col2 int;
2 Comments
mu is too short
You might want to reference the docs for posterity,
ALTER TABLE [ ONLY ] name [ * ] action [, ... ], postgresql.org/docs/current/static/sql-altertable.htmlBrian D
and to set the default value:
ALTER TABLE table ADD COLUMN col1 int default 0, ADD COLUMN col2 text default 'foo';ALTER TABLE IF EXISTS TABLEname
add ADD COLUMN IF NOT EXISTS column_name data_type [column_constraint];
detailed query where column_constraints are optional
1 Comment
Doug P
Ouch... Neither of the syntaxes above work in Redshift :-( I get errors: ERROR: syntax error at or near "," LINE 1: ALTER TABLE x ADD COLUMN col1 int, ADD COLUMN colX int