PostgreSQL: How to Rename a Column of a Table

Last updated on February 25, 2022 A Goodman Loading... Post a comment

In PostgreSQL, you can change the name of a column in a table by using the ALTER TABLE statement, like so:

ALTER TABLE table_name
   RENAME COLUMN <old_column_name> TO <new_column_name>;

For example, I have a table called users and I want to change the name of the password column to pwd:

ALTER TABLE users
   RENAME COLUMN password TO pwd;

It is possible to rename a column of a table via pgAdmin. What you need to do is to right-click on your table then select Properties from the menu:

A modal dialog will show up. Focus on the Columns tab and now you can modify the name of every column you want:

Finally, press the Save button and refresh your database to see your change.

Further reading:

You can also check out our database topic page for the latest tutorials and examples.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

You May Also Like