
Unlike unlogged tables, unlogged sequences do not offer a significant performance advantage. Unlogged sequences are also not replicated to standby servers. They are not crash-safe: an unlogged sequence is automatically reset to its initial state after a crash or unclean shutdown. Changes to unlogged sequences are not written to the write-ahead log. If specified, the sequence is created as an unlogged sequence. Existing permanent sequences with the same name are not visible (in this session) while the temporary sequence exists, unless they are referenced with schema-qualified names. If specified, the sequence object is created only for this session, and is automatically dropped on session exit. (Of course, this value might be obsolete by the time it's printed, if other sessions are actively doing nextval calls.) In particular, the last_value field of the sequence shows the last value allocated by any session. To examine the parameters and current state of a sequence.

These functions are documented in Section 9.17.Īlthough you cannot update a sequence directly, you can use a query like: The sequence name must be distinct from the name of any other relation (table, sequence, index, view, materialized view, or foreign table) in the same schema.Īfter a sequence is created, you use the functions nextval, currval, and setval to operate on the sequence. Temporary sequences exist in a special schema, so a schema name cannot be given when creating a temporary sequence. Otherwise it is created in the current schema. If a schema name is given then the sequence is created in the specified schema.

TYPES OF SEQUENCES GENERATOR
The generator will be owned by the user issuing the command. This involves creating and initializing a new special single-row table with the name name. CREATE SEQUENCE creates a new sequence number generator.
