In SQL, we can alter or rename or change the name of the table in SQL database either by using the”SP_RENAME” query or by using SQL Server Management Studio.
In SQL, by using the “SP_RENAME” statement we can change the name of Table in the database based on our requirements.
Following is the syntax of alter or rename the table in SQL server using sp_rename statement
SP_RENAME 'oldtablename', 'newtablename'
Here “oldtablename” is the name of the present table and “newtablename” is the new name for the table.
Following is the example query to change or rename the table name from “EmployeeDetails” to “EmployeeInformation”.
SP_RENAME 'EmployeeDetails', 'EmployeeInformation'
Now refresh your SQL database section and check for the table with a new name that would be like as shown below.
To change table name open SQL Server Management Studio à Select your database in Databases section à Go to Tables Section à Select your table à Right click and Select Rename Table like as shown below.
Once we click on the Rename option, it will allow us to modify a table name in that enter a required table name. Once we change the table name that will be like as shown below.