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.

Permissions

The role must have the DDL permission at the database or table level.

Syntax

alter_table_rename_table_statement ::=
    ALTER TABLE [schema_name.]current_name RENAME TO new_name
    ;

current_name ::= identifier

schema_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;