"Fossies" - the Fresh Open Source Software Archive

Member "drizzle-7.1.36-stable/docs/rename.rst" (6 May 2012, 844 Bytes) of package /linux/misc/old/drizzle-7.1.36-stable.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

RENAME

Rename a table, or group of tables.

If you have an existing table old_name, you can create another table new_name; it will be empty but reptant he same structure, and then replace the existing table with the empty one as follows (assuming backup_table does not already exist):

CREATE TABLE new_name (...);
RENAME TABLE old_name TO backup_table, new_name TO old_name;

When using a statement to rename more than one table, the order of operations are done from left to right. To swap two table names, use the following (assuming tmp_table does not already exist):

RENAME TABLE old_name TO tmp_table,
    new_name TO old_name,
    tmp_table TO new_name;

While RENAME is running, no other session can access any of the involved tables.

/alter_table