In sql, we can alter or rename or change the name of table in sql database either by using ”SP_RENAME” query or by using SQL Server Management Studio.
In sql, by using “SP_RENAME” statement we can change the name of Table in 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 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 table with 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 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.