Renaming Tables

The ALTER TABLE RENAME TO statement lets you rename one or more tables. Renaming tables does not change the table OID.

You rename multiple tables by supplying two comma-delimited lists.Vertica maps the names according to their order in the two lists. Only the first list can qualify table names with a schema. For example:

=> ALTER TABLE S1.T1, S1.T2 RENAME TO U1, U2;

The RENAME TO parameter is applied atomically : all tables are renamed, or none of them. For example, if the number of tables to rename does not match the number of new names, none of the tables is renamed.

Note: Renaming a table referenced by a view causes the view to fail, unless you create another table with the previous name to replace the renamed table.

Using Rename to Swap Tables Within a Schema

You can use ALTER TABLE RENAME TO to swap tables within the same schema, without actually moving data. You cannot swap tables across schemas.

To swap tables within a schema (example statement is split to explain steps):

  1. Enter the names of the tables to swap, followed by a new temporary table placeholder (temps):

    => ALTER TABLE T1, T2, temps 
  2. Use the RENAME TO clause to swap the tables: T1 to temps, T2 to T1, and temps to T2:

    RENAME TO temps, T1, T2;