postgresqlHow do I rename a column in PostgreSQL?
Renaming a column in PostgreSQL is a simple process and can be done using the ALTER TABLE
command.
Example code
ALTER TABLE table_name
RENAME COLUMN old_column_name TO new_column_name;
The code above will rename the column old_column_name
to new_column_name
in the table_name
table.
Code explanation
ALTER TABLE
- This command is used to modify the structure of an existing table.table_name
- This is the name of the table which contains the column to be renamed.RENAME COLUMN
- This command is used to rename an existing column.old_column_name
- This is the name of the column to be renamed.TO
- This keyword is used to separate the old and new column names.new_column_name
- This is the new name of the column.
Helpful links
More of Postgresql
- How can I use PostgreSQL's "zero if null" feature?
- How can I use PostgreSQL with YAML?
- How do I use PostgreSQL's XMLTABLE to parse XML data?
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How do I use PostgreSQL's XMIN and XMAX features?
- How can I view my PostgreSQL query history?
- How do I install PostgreSQL and Zabbix on my system?
- How do I parse XML data using PostgreSQL?
- How do I use the PostgreSQL NVL function?
See more codes...