1<!--$Id: intro.so,v 1.5 2006/11/13 18:05:03 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB Reference Guide: Introduction to sequences</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<a name="2"><!--meow--></a> 12<table width="100%"><tr valign=top> 13<td><b><dl><dt>Berkeley DB Reference Guide:<dd>Sequences</dl></b></td> 14<td align=right><a href="/txn/limits.html"><img src="/images/prev.gif" alt="Prev"></a><a href="/toc.html"><img src="/images/ref.gif" alt="Ref"></a><a href="/rpc/intro.html"><img src="/images/next.gif" alt="Next"></a> 15</td></tr></table> 16<p align=center><b>Introduction to sequences</b></p> 17<p>Sequences provide an arbitrary number of persistent objects that return 18an increasing or decreasing sequence of integers. Opening a sequence 19handle associates it with a record in a database. The handle can 20maintain a cache of values from the database so that a database update 21is not needed as the application allocates a value.</p> 22<p>A sequence is stored as a record pair in a database. The database may 23be of any type, but may not have been configured to support duplicate 24data items. The sequence is referenced by the key used when the 25sequence is created, therefore the key must be compatible with the 26underlying access method. If the database stores fixed-length records, 27the record size must be at least 64 bytes long.</p> 28<p>Since a sequence handle is opened using a database handle, the use of 29transactions with the sequence must follow how the database handle was 30opened. In other words, if the database handle was opened within a 31transaction, operations on the sequence handle must use transactions. 32Of course, if sequences are cached, not all operations will actually 33trigger a transaction.</p> 34<p>For the highest concurrency, caching should be used and the 35<a href="/api_c/env_set_flags.html#DB_AUTO_COMMIT">DB_AUTO_COMMIT</a> and <a href="/api_c/env_set_flags.html#DB_TXN_NOSYNC">DB_TXN_NOSYNC</a> flags should be 36specified to the <a href="/api_c/seq_get.html">DB_SEQUENCE->get</a> method call. If the allocation of the 37sequence value must be part of a transaction, and rolled back if the 38transaction aborts, then no caching should be specified and the 39transaction handle must be passed to the <a href="/api_c/seq_get.html">DB_SEQUENCE->get</a> method.</p> 40<!--$Id: m4.methods,v 1.7 2004/11/29 15:34:22 bostic Exp $--> 41<table border=1 align=center> 42<tr><th>Sequences and Related Methods</th><th>Description</th></tr> 43<!--DbSequence::--><tr><td><a href="/api_c/seq_class.html">db_sequence_create</a></td><td>Create a sequence handle</td></tr> 44<!--DbSequence::close--><tr><td><a href="/api_c/seq_close.html">DB_SEQUENCE->close</a></td><td>Close a sequence</td></tr> 45<!--DbSequence::get--><tr><td><a href="/api_c/seq_get.html">DB_SEQUENCE->get</a></td><td>Get the next sequence element(s)</td></tr> 46<!--DbSequence::get_dbp--><tr><td><a href="/api_c/seq_open.html">DB_SEQUENCE->get_dbp</a></td><td>Return a handle for the underlying sequence database</td></tr> 47<!--DbSequence::get_key--><tr><td><a href="/api_c/seq_open.html">DB_SEQUENCE->get_key</a></td><td>Return the key for a sequence</td></tr> 48<!--DbSequence::initial_value--><tr><td><a href="/api_c/seq_initial_value.html">DB_SEQUENCE->initial_value</a></td><td>Set the initial value of a sequence</td></tr> 49<!--DbSequence::open--><tr><td><a href="/api_c/seq_open.html">DB_SEQUENCE->open</a></td><td>Open a sequence</td></tr> 50<!--DbSequence::remove--><tr><td><a href="/api_c/seq_remove.html">DB_SEQUENCE->remove</a></td><td>Remove a sequence</td></tr> 51<!--DbSequence::stat--><tr><td><a href="/api_c/seq_stat.html">DB_SEQUENCE->stat</a></td><td>Return sequence statistics</td></tr> 52<tr><th>Sequences Configuration</th><th><br></th></tr> 53<!--DbSequence::set_cachesize--><tr><td><a href="/api_c/seq_set_cachesize.html">DB_SEQUENCE->set_cachesize</a></td><td>Set the cache size of a sequence</td></tr> 54<!--DbSequence::set_flags--><tr><td><a href="/api_c/seq_set_flags.html">DB_SEQUENCE->set_flags</a></td><td>Set the flags for a sequence</td></tr> 55<!--DbSequence::set_range--><tr><td><a href="/api_c/seq_set_range.html">DB_SEQUENCE->set_range</a></td><td>Set the range for a sequence</td></tr> 56</table> 57<table width="100%"><tr><td><br></td><td align=right><a href="/txn/limits.html"><img src="/images/prev.gif" alt="Prev"></a><a href="/toc.html"><img src="/images/ref.gif" alt="Ref"></a><a href="/rpc/intro.html"><img src="/images/next.gif" alt="Next"></a> 58</td></tr></table> 59<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 60</body> 61</html> 62