SQL Alter Table Name is used to change or modify name of the existing table. To understand how to change the name of created table in SQL Query, this tutorial brings you a simple example to understand it.
The Table 'Stu_Table' is created using create table statement. The insert into statement add records or rows to the table 'Stu_Table'. The inserted record from a table 'Stu_Table' is returned by the select statement. Now we want to change the name of Table 'Stu_Table' to 'Stu_Tab_10'. The Alter table Query will run ,which alter the name of existing table 'Stu_Table'. The Rename Query rename the Table 'Stu_Table' to 'Stu_Table_10'.Once the query is submitted, the successful Rename is displayed.
Create Table Stu_Table
create table Stu_Table(Stu_Id integer(2), Stu_Name varchar(15), Stu_Class varchar(10))
Insert data into Stu_Table
insert into Stu_Table values(1,'Komal',10); insert into Stu_Table values(2,'Ajay',10); insert into Stu_Table values(3,'Rakesh',10); insert into Stu_Table values(4,'Bhanu',10); insert into Stu_Table values(5,'Santosh',10);
SQL Alter Query
Alter table Stu_Table rename to Stu_Table_10)
Successful Rename ...
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial