SQL Alter (Rename) Table Statement

In SQL, we can alter or rename or change the table's name in the SQL database either by using the”SP_RENAME” query or by using SQL Server Management Studio.

SQL ALTER Table using Query

In SQL, by using the “SP_RENAME” statement, we can change the name of Table in the database based on our requirements.

SQL ALTER Table using Query Syntax

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.

SQL ALTER Table using Query Example

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, as shown below.

 

After changing or renaming table name in sql server

ALTER Table using SQL Server Management Studio

To change the 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.

 

Rename table in SQL Server using Management Studio

Once we click on the Rename option, it will allow us to modify a table name to enter a required table name. Once we change the table name, that will be like as shown below.

 

After changing or renaming table name in sql server