SQL RENAME Table - Javatpoint
SQL RENAME Table - Javatpoint
Any database user can easily change the name by using the RENAME TABLE and ALTER TABLE
statement in Structured Query Language.
The RENAME TABLE and ALTER TABLE syntax help in changing the name of the table.
Table: Cars
Suppose, you want to change the above table name into "Car_2021_Details". For this, you have to
type the following RENAME statement in SQL:
After this statement, the table "Cars" will be changed into table name "Car_2021_Details".
Suppose, you want to change the name of the above table into the "Coding_Employees". For
this, you have to type the following RENAME statement in SQL:
After this statement, the table "Employee" will be changed into the table name
"Coding_Employees".
In the Syntax, we have to specify the RENAME TO keyword after the old name of the table.
Here, we have taken the following three different SQL examples, which will help you how to change the
name of the table in the SQL database using ALTER TABLE statement:
Table : Bikes
Suppose, you want to change the name of the above table into "Bikes_Details" using ALTER
TABLE statement. For this, you have to type the following query in SQL:
After this statement, the table "Bikes" will be changed into the table name "Bikes_Details".
1001 Abhay 85
1002 Ankit 75
1003 Bheem 60
1004 Ram 79
1005 Sumit 80
Table : Student
Suppose, you want to change the name of the above table into "MCA_Student_Details" using
ALTER TABLE statement. For this, you have to type the following query in SQL:
After this statement, the table "Student" will be changed into table name "MCA_Student_Details".
Table: Employee
Suppose, you want to change the name of the above table into the "Coding_Employees" using
an ALTER TABLE statement. For this, you have to type the following query in SQL:
After this statement, the table "Employee" will be changed into the table name "Coding_Employees".
← Prev Next →
Youtube For Videos Join Our Youtube Channel: Join Now
Feedback
Preparation
Company
Interview
Questions
Company Questions
Trending Technologies