PostgreSQL – How to Rename a Table
To rename a table in PostgreSQL, you can use the ALTER TABLE
statement with the RENAME TO
clause. Here’s the basic syntax:
ALTER TABLE current_table_name RENAME TO new_table_name;
Replace current_table_name
with the name of the table you want to rename, and replace new_table_name
with the new name you want to give to the table.
Here’s an example of how to use this syntax to rename a table:
ALTER TABLE old_table RENAME TO new_table;
After executing this SQL statement, the table will be renamed from “old_table” to “new_table.” Please note that you need appropriate permissions to rename tables in PostgreSQL.