Renaming a table changes neither a table's structure nor its contents. The following statement renames table
t1 to t2:
ALTER TABLE t1 RENAME TO t2;
Another way to rename a table is by using the RENAME TABLE statement:
RENAME TABLE t1 TO t2;
RENAME TABLE has an advantage over ALTER TABLE in that it can perform multiple table renames in a single operation. One use for this feature is to swap the names of two tables:
RENAME TABLE t1 TO tmp, t2 TO t1, tmp TO t2;
For TEMPORARY tables, RENAME TABLE does not work. The ALTER TABLE command must be used instead.
Comments
Post a Comment