PostgreSQL – Rename Column

To rename a column in PostgreSQL, you can use the ALTER TABLE statement with the RENAME COLUMN option. Below is the syntax:

ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name;

Where table_name is the name of the table and old_column_name and new_column_name are the current name of the column and new name of the column. Example: Use the below command to rename a column name to full_name in table employees.

ALTER TABLE employees RENAME COLUMN name TO full_name;

When you rename a column, the new column name must not already exist in the table. Renaming a column will not affect any data stored in the column.

Similar Posts