C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
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 SQLRENAME old_table _name To new_table_name ; Examples 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
RENAME Cars To Car_2021_Details ;
Example 2: Let's take an example of a table named Employee:
Table: Employee
RENAME Employee To Coding_Employees ;
Syntax of ALTER TABLE statement in SQLALTER TABLE old_table_name RENAME TO new_table_name; In 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
ALTER TABLE Bikes RENAME TO Bikes_Details ; 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
ALTER TABLE Student RENAME TO MCA_Student_Details ; 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
ALTER TABLE Employee RENAME To Coding_Employees ; After this statement, the table "Employee" will be changed into the table name "Coding_Employees".
Next TopicSQL TRUNCATE TABLE
|