13.6. More Database Objects


In SQL, a sequence is a database object that automatically generates a succession of values—note that this is a completely different meaning of the word “sequence” from its usage in XQuery, as we’ll see later. Sequence objects were first introduced in SQL:2003 and are useful whenever it’s necessary to produce a unique key value. Having the unique value generated inside the database, instead of in an external application, reduces the possibility of issues arising in areas such as performance and concurrency. Some SQL implementations may precompute the next values in a sequence and cache these ready for immediate use.

In some respects, a sequence is similar to an identity column in a table. However, unlike ...

Get Information Modeling and Relational Databases, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.