SQL RENAME TABLE

SQL RENAME TABLE syntax is used to change the name of a table. Sometimes, we choose non-meaningful name for the table. So it is required to be changed.

Let's see the syntax to rename a table from the database.

  • ALTER TABLE table_name
  • RENAME TO new_table_name;

Optionally, you can write following command to rename the table.

RENAME old_table _name To new_table_name;

Let us take an example of a table named "EMPLOYEE", now due to some reason we want to change it into table name "hcl".

Table- EMPLOYEE

Mithilesh 24 Noida
Harish 23 Ghaziabad
Amit Vasundhra 25

You should use any one of the following syntax to RENAME the table name:

ALTER TABLE EMPLOYEE RENAME TO hcl;

or

RENAME STUDENTS TO hcl; After that the table " EMPLOYEE " will be changed into table name " hcl "