Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add multiple columns to a table in Postgres?

People also ask

How do I add a column to an existing table in PostgreSQL?

Syntax. The syntax to add a column in a table in PostgreSQL (using the ALTER TABLE statement) is: ALTER TABLE table_name ADD new_column_name column_definition; table_name.

How do you add columns in Pgadmin?

Adding a New column To add a new column to a PostgreSQL table, the ALTER TABLE command is used with the following syntax: ALTER TABLE table-name ADD new-column-name column-definition; The table-name is the name of the table to be modified. The new-column-name is the name of the new column to be added.

How do I create columns in PostgreSQL?

Execute the a SQL statement in 'psql' to get the column names of a PostgreSQL table. SELECT column_name FROM INFORMATION_SCHEMA. COLUMNS WHERE TABLE_NAME = 'some_table'; NOTE: Make sure to replace the some_table string that's enclosed in single quotes with an actual table name before you execute the SQL statement.


Try this :

ALTER TABLE table ADD COLUMN col1 int, ADD COLUMN col2 int;

ALTER TABLE  IF EXISTS  TABLEname 
add ADD  COLUMN   IF NOT EXISTS  column_name data_type  [column_constraint];

detailed query where column_constraints are optional