How to change a table name using an SQL query?
How can I in change the table name using a query statement?
I used the following syntax but I couldn't find the rename keyword in SQL server 2005.
Alter table Stu_Table rename to Stu_Table_10
Use sp_rename:
EXEC sp_rename 'Stu_Table', 'Stu_Table_10'
You can find documentation on this procedure on MSDN.
If you need to include a schema name, this can only be included in the first parameter (that is, this cannot be used to move a table from one schema to another). So, for example, this is valid:
EXEC sp_rename 'myschema.Stu_Table', 'Stu_Table_10'
In MySQL
:-
RENAME TABLE `Stu Table` TO `Stu Table_10`
In Postgress SQL:
Alter table student rename to student_details;
Please use this on SQL Server 2005:
sp_rename old_table_name , new_table_name
it will give you:
Caution: Changing any part of an object name could break scripts and stored procedures.
but your table name will be changed.