~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/rename.rst

  • Committer: Brian Aker
  • Date: 2011-02-12 08:10:17 UTC
  • mto: This revision was merged to the branch mainline in revision 2161.
  • Revision ID: brian@tangent.org-20110212081017-7793i41ybt7gp5ty
More removal of session from includes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
Rename a table, or group of tables.
5
5
 
6
 
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):
7
 
 
8
 
.. code-block:: mysql
9
 
 
10
 
        CREATE TABLE new_name (...);
11
 
        RENAME TABLE old_name TO backup_table, new_name TO old_name;
12
 
 
13
 
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):
14
 
 
15
 
.. code-block:: mysql
16
 
 
17
 
        RENAME TABLE old_name TO tmp_table,
18
 
        new_name TO old_name,
19
 
        tmp_table TO new_name;
20
 
 
21
 
While RENAME is running, no other session can access any of the involved tables. 
22
 
 
23
 
.. seealso::
24
 
   :doc:`/alter_table`
 
6
See :doc:`/alter_table`