A sequence is a database object that generates unique numbers, mostly used for primary key values. One can select the NEXTVAL and CURRVAL from a sequence. Selecting the NEXTVAL will automatically increment the sequence.
CREATE [ TEMPORARY | TEMP ] SEQUENCE seqname [ INCREMENT increment ]
[ MINVALUE minvalue ] [ MAXVALUE maxvalue ]
[ START start ] [ CACHE cache ] [ CYCLE ]
CREATE SEQUENCE will enter a new sequence number generator into the current database. This involves creating and initializing a new single-row table with the name seqname. The generator will be owned by the user issuing the command.
If a schema name is given then the sequence is created in the specified schema.
Otherwise it is created in the current schema (the one at the front of the search path; see CURRENT_SCHEMA()). TEMP sequences exist in a special schema, so a schema name may not be given when creating a TEMP sequence. The sequence name must be distinct from the name of any other sequence, table, index, or view in the same schema.
Names the sequence. The name, including the implicit or explicit qualifier, must not identify a sequence or data area that already exists at the current server. If a qualified function name is specified, the schema-name cannot be QSYS2, QSYS, or SYSIBM.
For more information , please do visit source site:
http://www.sql.org/sq l-databas e/postgresql/manual/sql-create seque nce.htm
Answered by
Raksha
, an ibibo Master,
at
9:32 AM on June 18, 2008