SQL RENAME TABLEIn some situations, database administrators and users want to change the name of the table in the SQL database because they want to give a more relevant name to the table. 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. Syntax of RENAME statement in SQLExamples of RENAME statement in SQLHere, we have taken the following two different SQL examples, which will help you how to change the name of the SQL table in the database using RENAME statement: Example 1: Let's take an example of a table named Cars:
Table: Cars
Example 2: Let's take an example of a table named Employee:
Table: Employee
Syntax of ALTER TABLE statement in SQLIn the Syntax, we have to specify the RENAME TO keyword after the old name of the table. Examples of ALTER TABLE statement in SQLHere, 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: Example 1: Let's take an example of a table named Bikes:
Table : Bikes
After this statement, the table "Bikes" will be changed into the table name "Bikes_Details". Example 2: Let's take an example of a table named Student:
Table : Student
After this statement, the table "Student" will be changed into table name "MCA_Student_Details". Example 3: Let's take an example of a table named Employee:
Table: Employee
After this statement, the table "Employee" will be changed into the table name "Coding_Employees". Next TopicSQL TRUNCATE TABLE |