1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Allow ALTER SEQUENCE START WITH to change the recorded start_value of a

sequence.  This seems an obvious extension to the recent patch, and it
makes the code noticeably cleaner and more orthogonal.
This commit is contained in:
Tom Lane
2008-05-17 01:20:39 +00:00
parent 3951fae51d
commit caede71b44
2 changed files with 59 additions and 50 deletions

View File

@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_sequence.sgml,v 1.20 2008/05/16 23:36:04 tgl Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_sequence.sgml,v 1.21 2008/05/17 01:20:39 tgl Exp $
PostgreSQL documentation
-->
@ -26,7 +26,9 @@ PostgreSQL documentation
<synopsis>
ALTER SEQUENCE <replaceable class="parameter">name</replaceable> [ INCREMENT [ BY ] <replaceable class="parameter">increment</replaceable> ]
[ MINVALUE <replaceable class="parameter">minvalue</replaceable> | NO MINVALUE ] [ MAXVALUE <replaceable class="parameter">maxvalue</replaceable> | NO MAXVALUE ]
[ RESTART [ [ WITH ] <replaceable class="parameter">start</replaceable> ] ] [ CACHE <replaceable class="parameter">cache</replaceable> ] [ [ NO ] CYCLE ]
[ START [ WITH ] <replaceable class="parameter">start</replaceable> ]
[ RESTART [ [ WITH ] <replaceable class="parameter">restart</replaceable> ] ]
[ CACHE <replaceable class="parameter">cache</replaceable> ] [ [ NO ] CYCLE ]
[ OWNED BY { <replaceable class="parameter">table</replaceable>.<replaceable class="parameter">column</replaceable> | NONE } ]
ALTER SEQUENCE <replaceable class="parameter">name</replaceable> RENAME TO <replaceable class="parameter">new_name</replaceable>
ALTER SEQUENCE <replaceable class="parameter">name</replaceable> SET SCHEMA <replaceable class="parameter">new_schema</replaceable>
@ -110,17 +112,31 @@ ALTER SEQUENCE <replaceable class="parameter">name</replaceable> SET SCHEMA <rep
<varlistentry>
<term><replaceable class="parameter">start</replaceable></term>
<listitem>
<para>
The optional clause <literal>START WITH <replaceable
class="parameter">start</replaceable></literal> changes the
recorded start value of the sequence. This has no effect on the
<emphasis>current</> sequence value; it simply sets the value
that future <command>ALTER SEQUENCE RESTART</> commands will use.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">restart</replaceable></term>
<listitem>
<para>
The optional clause <literal>RESTART [ WITH <replaceable
class="parameter">start</replaceable> ]</literal> changes the
class="parameter">restart</replaceable> ]</literal> changes the
current value of the sequence. This is equivalent to calling the
<function>setval</> function with <literal>is_called</literal> =
<literal>false</>: the specified value will be returned by the
<emphasis>next</> call of <function>nextval</>.
Writing <literal>RESTART</> with no <replaceable
class="parameter">start</replaceable> value is equivalent to supplying
the start value used when the sequence was created.
class="parameter">restart</> value is equivalent to supplying
the start value that was recorded by <command>CREATE SEQUENCE</>
or last set by <command>ALTER SEQUENCE START WITH</>.
</para>
</listitem>
</varlistentry>
@ -261,7 +277,8 @@ ALTER SEQUENCE serial RESTART WITH 105;
<para>
<command>ALTER SEQUENCE</command> conforms to the <acronym>SQL</acronym>
standard, except for the <literal>OWNED BY</>, <literal>RENAME</>, and
standard, except for the <literal>START WITH</>,
<literal>OWNED BY</>, <literal>RENAME</>, and
<literal>SET SCHEMA</literal> clauses, which are
<productname>PostgreSQL</productname> extensions.
</para>