SEQUENCE NAME syntax not documented for ALTER TABLE
SEQUENCE NAME syntax not documented for ALTER TABLE
От:
Rene Saarsoo <nene@triin.net>
Дата:
The documentation for ALTER TABLE [1] doesn't make it clear that the following is allowed:ALTER TABLE tbl ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY ( SEQUENCE NAME my_name );
It only references the sequence options allowed in CREATE SEQUENCE or ALTER SEQUENCE, unlike the CREATE TABLE [2] documentation, which does specifically state [3]:
> The available options include those shown for CREATE SEQUENCE,
> plus
SEQUENCE NAME name, LOGGED, and UNLOGGEDWith best,
Rene Saarsoo
Re: SEQUENCE NAME syntax not documented for ALTER TABLE
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Rene Saarsoo writes:
> The documentation for ALTER TABLE [1] doesn't make it clear that the
> following is allowed:
> ...
> It only references the sequence options allowed in CREATE SEQUENCE or ALTER
> SEQUENCE, unlike the CREATE TABLE [2] documentation, which does
> specifically state [3]:
Huh? I see
ADD GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY
SET GENERATED { ALWAYS | BY DEFAULT }
DROP IDENTITY [ IF EXISTS ]
These forms change whether a column is an identity column or change the
generation attribute of an existing identity column.
See CREATE TABLE for details.
Where do you see a pointer to CREATE SEQUENCE on that page?
regards, tom lane
Re: SEQUENCE NAME syntax not documented for ALTER TABLE
От:
Rene Saarsoo <nene@triin.net>
Дата:
On Sun, 23 Mar 2025 at 17:31, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Where do you see a pointer to CREATE SEQUENCE on that page?
Sorry, my mistake. The page only points to ALTER SEQUENCE.
Now I also see that separate section about ADD GENERATED etc,
which I completely missed earlier. I was searching for a definition of
sequence_options which is nowhere to be found on that page.So I searched for the next best thing sequence_option (in singular)and found the SET sequence_option section. I expected the definitionof sequence_options to just be the plural of sequence_option.But confusingly it's not.
I personally would really prefer if this information was part of the mainsyntax diagram, not somewhere deep inside the text. But I might bean odd user of the documentation as I'm trying to write a parser forPostgreSQL.
Regards,Rene Saarsoo