MySQL Wildcards

MySQL Wildcards

MySQL Aliases

MySQL Aliases

MySQL Data Types

MySQL Data Types

MySQL Interview Questions

MySQL Interview Questions and Answers


MySQL Rename Table

MySQL Rename TABLE statement rename the existing table name. RENAME TABLE renames one or more tables. You must have ALTER and DROP privileges for the original table, and CREATE and INSERT privileges for the new table. In addition to the tables, we can use the RENAME TABLE statement to rename views.

Note: You cannot use the RENAME TABLE statement to rename a temporary table, but you can use the ALTER TABLE statement to rename a temporary table.

MySQL RENAME TABLE Syntax

To rename the existing table, use the following syntax:

Syntax

RENAME TABLE oldtablename TO newtablename;

OR

ALTER TABLE oldtablename RENAME TO newtablename;

Parameters:

oldtablename: The old table name that you want to rename.

newtablename: The new table name for the existing table.

MySQL RENAME TABLE examples

The following MySQL statement to rename existing table:

Example

RENAME TABLE tblCustomerLoan TO tblBankCustomer;

OR

ALTER TABLE tblCustomerLoan RENAME TO tblBankCustomer;

Note:

In the above example, we rename the existing table "tblCustomerLoan" to "tblBankCustomer".

You can use MySQL Command Line Client to rename existing table name from "tblCustomerLoan" to "tblBankCustomer". It will look like this:

Show RENAME TABLE

You can check the renamed table name by the following query:

Example

SHOW tables;  

You can use MySQL Command Line Client to show renamed table name. It will look like this: