In this Tutorial we will see how to change or rename the column name in Postgresql with example. Let’s see
- How to (change) rename the column name of Single column in Postgresql
- How to (change) rename the column name of Multiple column in Postgresql
With an example for each.
ALTER TABLE table_name RENAME COLUMN column_name TO new_column_name;
The table that we use is
Rename or Change single column name in postgresql :
Lets rename the single column
ALTER TABLE odetails RENAME COLUMN ono TO order_no;
So the result is
Rename or change the column name of multiple columns in postgresql:
We can rename only one column at a time. In order to rename multiple column we have to specify syntax multiple times.
ALTER TABLE odetails RENAME COLUMN ono TO order_no; ALTER TABLE odetails RENAME COLUMN bno TO batch_no;
So we renamed both the column so the result will be