From 9380e5f129d2a160ecc2444f61bb7cb97fd51fbb Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Mon, 19 Aug 2024 20:18:03 -0400 Subject: doc: improve create/alter sequence CYCLE syntax Reported-by: Peter Smith Discussion: https://postgr.es/m/CAHut+PtqwZwPfGq62xq2614_ce2ejDmbB9CfP+a1azxpneFRBQ@mail.gmail.com Author: Peter Smith Backpatch-through: master --- doc/src/sgml/ref/alter_sequence.sgml | 67 ++++++++++++++++++----------------- doc/src/sgml/ref/create_sequence.sgml | 54 ++++++++++++++-------------- 2 files changed, 62 insertions(+), 59 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/alter_sequence.sgml b/doc/src/sgml/ref/alter_sequence.sgml index 7be36cf466d..a998ccc7ead 100644 --- a/doc/src/sgml/ref/alter_sequence.sgml +++ b/doc/src/sgml/ref/alter_sequence.sgml @@ -27,9 +27,10 @@ ALTER SEQUENCE [ IF EXISTS ] name [ AS data_type ] [ INCREMENT [ BY ] increment ] [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ] + [ [ NO ] CYCLE ] [ START [ WITH ] start ] [ RESTART [ [ WITH ] restart ] ] - [ CACHE cache ] [ [ NO ] CYCLE ] + [ CACHE cache ] [ OWNED BY { table_name.column_name | NONE } ] ALTER SEQUENCE [ IF EXISTS ] name SET { LOGGED | UNLOGGED } ALTER SEQUENCE [ IF EXISTS ] name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER } @@ -154,6 +155,38 @@ ALTER SEQUENCE [ IF EXISTS ] name S + + CYCLE + + + The optional CYCLE key word can be used to enable + the sequence to wrap around when the + maxvalue or + minvalue has been + reached by + an ascending or descending sequence respectively. If the limit is + reached, the next number generated will be the + minvalue or + maxvalue, + respectively. + + + + + + NO CYCLE + + + If the optional NO CYCLE key word is + specified, any calls to nextval after the + sequence has reached its maximum value will return an error. + If neither CYCLE or NO + CYCLE are specified, the old cycle behavior will be + maintained. + + + + start @@ -207,38 +240,6 @@ ALTER SEQUENCE [ IF EXISTS ] name S - - CYCLE - - - The optional CYCLE key word can be used to enable - the sequence to wrap around when the - maxvalue or - minvalue has been - reached by - an ascending or descending sequence respectively. If the limit is - reached, the next number generated will be the - minvalue or - maxvalue, - respectively. - - - - - - NO CYCLE - - - If the optional NO CYCLE key word is - specified, any calls to nextval after the - sequence has reached its maximum value will return an error. - If neither CYCLE or NO - CYCLE are specified, the old cycle behavior will be - maintained. - - - - SET { LOGGED | UNLOGGED } diff --git a/doc/src/sgml/ref/create_sequence.sgml b/doc/src/sgml/ref/create_sequence.sgml index 34e9084b5cc..1e283f13d15 100644 --- a/doc/src/sgml/ref/create_sequence.sgml +++ b/doc/src/sgml/ref/create_sequence.sgml @@ -25,7 +25,9 @@ CREATE [ { TEMPORARY | TEMP } | UNLOGGED ] SEQUENCE [ IF NOT EXISTS ] data_type ] [ INCREMENT [ BY ] increment ] [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ] - [ START [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ] + [ [ NO ] CYCLE ] + [ START [ WITH ] start ] + [ CACHE cache ] [ OWNED BY { table_name.column_name | NONE } ] @@ -193,6 +195,31 @@ SELECT * FROM name; + + CYCLE + NO CYCLE + + + The CYCLE option allows the sequence to wrap + around when the maxvalue or minvalue has been reached by an + ascending or descending sequence respectively. If the limit is + reached, the next number generated will be the minvalue or maxvalue, respectively. + + + + If NO CYCLE is specified, any calls to + nextval after the sequence has reached its + maximum value will return an error. If neither + CYCLE or NO CYCLE are + specified, NO CYCLE is the default. + + + + start @@ -221,31 +248,6 @@ SELECT * FROM name; - - CYCLE - NO CYCLE - - - The CYCLE option allows the sequence to wrap - around when the maxvalue or minvalue has been reached by an - ascending or descending sequence respectively. If the limit is - reached, the next number generated will be the minvalue or maxvalue, respectively. - - - - If NO CYCLE is specified, any calls to - nextval after the sequence has reached its - maximum value will return an error. If neither - CYCLE or NO CYCLE are - specified, NO CYCLE is the default. - - - - OWNED BY table_name.column_name OWNED BY NONE -- cgit v1.2.3