Renaming SQL table refers to the process of changing the name of an existing table to a new name.
This is useful when you want to assign a meaningful name to the table and to standardize the naming convention of tables within a database.
"sp_rename" store procedure is used to rename existing table to a new name. Here's the syntax :
sp_rename 'old_table_name' , 'new_table_name' ;
As you can see in below image, [Product] table is present under [SQL Tutorial] database. Let's rename it as [ProductMaster].
1. Run below SQL command in SSMS and "Ignore the given warning message" :
USE [SQL Tutorial]; GO sp_rename 'Product' , 'productMaster' ;
2. Above command will rename [Product] table as [ProductName].
That's it! You have successfully renamed [Product] table as [ProductMaster] using T-SQL.
1. Expand the database that contains the table you want to rename >> Right-click on the table you want to rename in "Tables folder" >> Select "Rename".
2. It will let you edit in table name, type the new table name >> Click "Enter".
3. A message will appear asking you to confirm if you really want change the table name >> Select "Yes".
4. There you go, [Product] table is renamed as [ProductMaster].
That's it! You have successfully renamed [Product] table as [ProductMaster] using GUI.
To rename a table in SQL, use the "ALTER TABLE" statement followed by the "RENAME TO" clause.
"RENAME" is not a standalone command in SQL, but it's used within specific statements like "ALTER TABLE" for renaming tables.
The rename function in SQL is a capability within the "ALTER TABLE" statement that allows changing the name of a table.
You change the name of a table in SQL by using the "ALTER TABLE" statement followed by "RENAME TO" and specifying the new table name.