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.
- 2 Ways to View the Structure of a Table in PostgreSQL
- Unsigned (non-negative) Integer in PostgreSQL
- 2 Ways to Rename a Table in PostgreSQL
- 2 Ways to Get the Size of a Database in PostgreSQL
- Using ENUM Type in TypeORM
You can also check out our database topic page for the latest tutorials and examples.