All Products
Search
Document Center

RENAME TABLE

Last Updated: Jun 18, 2021

Description

You can execute the RENAME TABLE statement to rename one or more tables.

Syntax

RENAME TABLE tblname TO newtblname 
     [, tb1name2 TO newtblname …] ;

Parameters

Parameter

Description

tblname

The name of the original table.

newtblname

The name of the new table.

tblname TO newtblname

[, tb1name2 TO newtblname …] ;

To rename multiple tables at a time, separate the table names with commas (,).

Notes

  • After you execute the RENAME TABLE statement, the specified tables are automatically renamed. When the tables are being renamed, other threads cannot read data from the tables.
  • If you execute this statement to rename multiple tables, the tables are renamed in the left-to-right order.
  • To execute the RENAME TABLE statement, ensure that no tables are locked or involved in active transactions. To execute the RENAME TABLE statement, ensure that you have the ALTER and DROP permissions on the original table and the CREATE and INSERT permissions on the new table.
  • You can execute the RENAME TABLE statement to rename views.

Examples

  1. Create tables t1 and t2.
create table t1(c1 int);

create table t2(c1 int);
  1. Rename table t1 to t11.
rename table t1 to t11;
  1. Rename table t11 to t111 and table t2 to t22.
rename table t11 to t111, t2 to t22;
  1. Rename table t111 to t1111, and then rename table t1111 to t1.
rename table t111 to t1111, t1111 to t1;