RENAME TABLE

RENAME TABLE can be used to rename a table.

Warning

Renaming a table can void existing views that use this table. See more about recompiling views.

Syntax

ALTER TABLE [schema_name.]current_name RENAME TO new_name

schema_name ::= identifier

current_name ::= identifier

new_name ::= identifier

Parameters

Parameter

Description

schema_name

The schema name for the table. Defaults to public if not specified

current_name

The table name to apply the change to

new_name

The new table name

Examples

Renaming a Table

ALTER TABLE
  public.users RENAME TO former_users;

Permissions

The role must have the DDL permission on the table (or SUPERUSER on the table’s schema or database), and USAGE on the table’s schema. DDL granted at the database level does not satisfy this.