![]() ![]() ![]() The above snippet shows that the selected table has been altered successfully. Run the following query to rename a table in PostgreSQL: ALTER TABLE team_info Step 3: Rename the Selected Table Using RENAME TO Clause Run the SELECT statement to get the details of the team_info table: SELECT * FROM team_info Let’s say we need to rename the “team_info” table to “team_details”. Step 2: Check the Table Details Using SELECT Statement The output of \dt command shows that there are 9 tables available in the example database. Run the below-mentioned command in the SQL SHELL to see the list of available tables in the selected database i.e. Step 1: Check the Available Tables in the Selected Database Using \dt Command Open the SQL SHELL, connect to a database of your choice and perform the following steps to rename a table: New_name represents the table’s new/altered name.Īll in all, on successful execution of the above-given query, the table’s Old_name will be renamed to New_name.Įxample: How to Use RENAME TO Clause in PostgreSQL? RENAME TO is a clause in PostgreSQL that is used to RENAME a table. Old_name represents the table’s original/existing name. ALTER TABLE is a statement that is used to alter a table. The below syntax shows the basic usage of the RENAME TO clause: ALTER TABLE Old_name In PostgreSQL, the RENAME TO clause is used to rename a specific table. In this write-up, we will explain how to rename a table using the ALTER TABLE statement. The ALTER TABLE command offers a wide range of functionalities, for example, dropping a table/column, renaming a table/column, etc. In PostgreSQL, the RENAME clause is used with the aid of the ALTER TABLE statement to rename an already existing table. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |