Полезная информация

next up previous contents index
Next: Creating Sequences Up: Unique Row Identifiers Previous: Object Id Limitations

Sequences

POSTGRESQL has another way of assigning unique id's to rows. They are called sequences. With sequences, each table is given its own counter. The values are assigned to a specific table from the counter. Sequence numbers are unique only within that table. The advantage of sequences is that there are no gaps in numeric assignment, as happens with OIDs.9.4 Sequences are ideal for user-visible id's. If a customer was created today, and another one tomorrow, the two customers would have sequential numbers assigned to them. For the customer table's order_id, if the order id is visible to users, it is best to use a sequence number for this because sequence numbers don't have gaps. OIDs have gaps when INSERTs occur in other tables.


Bruce Momjian
1999-11-21