MySQL table rename
How to rename a table through SQL code and how to move a table between two databases.
You can rename any table using the rename sql command.
Please note that previously present data will NOT be lost
Sintax
RENAME TABLE [old_database.]old_table TO [new_database.]new_table;
As described, the origin and destination database name are optional; they should be included only when you want to move the table between two databases. If you would just rename the table, and thus wouldn't need to move in another database, the command will be:
RENAME TABLE old_table TO new_table;
Example
If you want to move the "customers" table to another database, here's the code:
RENAME TABLE project.customers TO project2.customers2;
If you only want to rename the same table from "customers" to "customers2" instead here is the solution:
RENAME TABLE customers TO customers2;
Publication details
Category: MySQL
Published by: loryzz on date: 06.03.2008 23:20:15
Last edit by: loryzz on date: 02.04.2008 16:54:26
Ratings
Leave a comment
All comments must be approved by site administrator.
Please write comments on topic. Spam will be never approved.
MySQL: Linked articles
SQL: Selezionare righe duplicate published by loryzz in MySQL
Problemi di FLOAT published by loryzz in MySQL
Password di root dimenticata published by loryzz in MySQL
Selezione condizionale published by loryzz in MySQL
Backup & Restore published by loryzz in MySQL
























Ritorna all'inizio
Based total comments
0 %
Comments percentage
0 %