From: | Jason Song <pidaoh(at)g(dot)skku(dot)edu> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Does RENAME TABLE rename associated identity sequence? |
Date: | 2025-04-23 12:36:21 |
Message-ID: | CAK9ZnjPRH04S5foDBh82ymP+jgQbYFiQ8E9TMQisSr8bhnUbDg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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!
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2025-04-23 12:46:13 | Re: POC: enable logical decoding when wal_level = 'replica' without a server restart |
Previous Message | Matheus Alcantara | 2025-04-23 12:18:48 | Re: extension_control_path and "directory" |