All Products
Search
Document Center

ApsaraDB RDS:What do I do if the "relation "xxx" already exists" error message is displayed when I attempt to modify a table name in an ApsaraDB RDS for PostgreSQL instance?

Last Updated:Aug 24, 2023

Problem description

I execute the following SQL statement to modify a capitalized table name in my ApsaraDB RDS for PostgreSQL instance:

alter table testtable rename to TESTTABLE

The following error message is returned:

ERROR: relation "testtable" already exists

Causes

In ApsaraDB RDS for PostgreSQL, table names are not case-sensitive by default.

Solutions

Enclose a capitalized table name in double quotation marks ("). Example:

alter table testtable rename "TESTTABLE";
Note

You must use the capitalized table name for subsequent queries.

Applicable scope

ApsaraDB RDS for PostgreSQL