Skip to content Skip to sidebar Skip to footer

Rename A Mysql Table Using Sql Statement

I want to rename an existing table using SQL statement: I have already tried: mysql_query('RENAME '$renameFolder' TO '$newName''); mysql_query('ALTER TABLE '$renameFolder' RENAME

Solution 1:

Try using backquotes instead, e.g.:

mysql_query( "RENAME TABLE `" . $renameFolder . "` TO `" . $newname . "`" );

Solution 2:

appected answer from mySQLi:

$db=mysqli_connect("localhost","root","password","database");
$oldFolder="old_table_name";
$newname="new_table_name";
mysqli_query($db,"RENAME TABLE `" . $oldFolder . "` TO `" . $newname . "`");

Good Luck!

Solution 3:

Have you connected to the server properly?

Have you selected the db the table is in?

If you have, then you should be able to run this:

mysql_query("ALTER TABLE table_name RENAME TO new_table_name");

Solution 4:

The mysql query for rename table is RENAME TABLE old_name TO new_name

Solution 5:

RENAME TABLE `jshop`.`mob_apple` TO `jshop`.`item_mobile`;

Post a Comment for "Rename A Mysql Table Using Sql Statement"