Does RENAME TABLE rename associated identity sequence? - Mailing list pgsql-hackers

From Jason Song
Subject Does RENAME TABLE rename associated identity sequence?
Date
Msg-id CAK9ZnjPRH04S5foDBh82ymP+jgQbYFiQ8E9TMQisSr8bhnUbDg@mail.gmail.com
Whole thread Raw
Responses Re: Does RENAME TABLE rename associated identity sequence?
List pgsql-hackers
Hi hackers,

I was wondering if there's any built-in functionality in PostgreSQL where renaming a table with an identity column would also rename the auto-generated sequence associated with that identity column.

In my case, I renamed a table that used `GENERATED BY DEFAULT AS IDENTITY`, and later when I ran `pg_dump`, I noticed that the sequence name was unchanged (e.g., still `old_table_id_seq`). As a result, any `setval()` or sequence-related operations referenced the old sequence name, even though the table name had changed.

I realize this can be worked around — for example, by using `--exclude-table-data` to skip the `setval()` or manually renaming the sequence after the table rename. But I'm curious if there are any plans (or technical reasons against) supporting something like `ALTER TABLE ... RENAME ... WITH SEQUENCE`, or having the sequence name automatically follow the table rename when it was originally auto-generated by an identity column.

Thanks for your time!

pgsql-hackers by date:

Previous
From: Matheus Alcantara
Date:
Subject: Re: extension_control_path and "directory"
Next
From: Amit Kapila
Date:
Subject: Re: POC: enable logical decoding when wal_level = 'replica' without a server restart