Provided by: manpages-zh_1.5.2-1_all bug

NAME

       CREATE SEQUENCE -

SYNOPSIS

       CREATE [ TEMPORARY | TEMP ] SEQUENCE name [ INCREMENT [ BY ] increment ]
           [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ]
           [ START [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ]

DESCRIPTION

       CREATE SEQUENCE   name

         nextval, currval, setval  ``Sequence-Manipulation Functions''

       SELECT * FROM name;

         last_value   ---  nextval

PARAMETERS

       TEMPORARY or TEMP

       name

       increment
              INCREMENT BY increment   1

       minvalue

       NO MINVALUE
                MINVALUE minvalue    NO MINVALUE  1  -263-1

       maxvalue

       NO MAXVALUE
                MAXVALUE maxvalue    NO MAXVALUE  263-1 -1

       start
                START WITH start     minvalue   maxvalue.

       cache  CACHE cache   1,

       CYCLE

       NO CYCLE
               CYCLE maxvalue  minvalue   minvalue  maxvalue

                NO CYCLE  nextval   CYCLE  NO CYCLE  NO CYCLE

NOTES

         DROP SEQUENCE

            bigint    -9223372036854775808     9223372036854775807     integer
       -2147483648  +2147483647

         cache    last_value  cache-1  nextval  ""

          cache   10 A  1..10  nextval=1  B  11..20  A  nextval=2   nextval=11
       cache  nextval   cache   nextval  last_value  nextval

         setval

EXAMPLES

         serial 101

       CREATE SEQUENCE serial START 101;

       SELECT nextval('serial');

        nextval
       ---------
            114

         INSERT

       INSERT INTO distributors VALUES (nextval('serial'), 'nothing');

         COPY FROM

       BEGIN;
       COPY distributors FROM 'input_file';
       SELECT setval('serial', max(id)) FROM distributors;
       END;

COMPATIBILITY

       CREATE SEQUENCE  PostgreSQL    SQL  CREATE SEQUENCE

       Postgresql  <laser@pgsqldb.org>