Loading...
X

How to rename a table in phpMyAdmin and MySQL

How to rename a table in phpMyAdmin

Open the database and then navigate to the table you want to rename.

When the table is open, select the “Operations” menu item.

Locate the “Move table to (database.table)” section. Yes, renaming uses the same function as moving a table to another database.

Enter a new table name and click the “Go” button.

Now the table has been given a new name.

How to rename a table in MySQL

To connect to MySQL or MariaDB DBMS on localhost without a password, use the command:

mysql -u root

To connect to MySQL or MariaDB DBMS on localhost with a password, use the command:

mysql -u root -p

Note that you do not need to specify a password after the -p option – you will need to enter the password at the command prompt.

If you are connecting to a remote server, then you can also use the -h (or --host=NAME) option with the host name or IP address.

After connecting to MySQL/MariaDB you can use the following command:

RENAME TABLE `DATABASE`.`TABLE NAME` TO `DATABASE`.`NEW TABLE NAME`;

You can also choose which database to use and leave out the database name next to the table name:

USE `DATABASE`;
RENAME TABLE `TABLE NAME` TO `NEW TABLE NAME`;

An example of renaming a table in MySQL:

RENAME TABLE `test`.`OLD NAME` TO `test`.`NEW NAME`;

An example of renaming a table in MySQL with database preselection:

USE `test`;
RENAME TABLE `OLD NAME` TO `NEW NAME`;

To list tables, use the following SQL query:

SHOW TABLES;


Leave Your Observation

Your email address will not be published. Required fields are marked *