db_close.html   [plain text]


<!--$Id: db_close.so,v 11.15 2002/08/18 21:17:23 bostic Exp $-->
<!--$Id: m4.tcl,v 11.28 2004/12/16 19:13:05 bostic Exp $-->
<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB: db close</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<table width="100%"><tr valign=top>
<td>
<b><i>db</i> <b>close</b></b>
</td>
<td align=right>
<a href="../api_tcl/api_tcl.html"><img src="../images/api.gif" alt="API"></a>
<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td>
</tr></table>
<hr size=1 noshade>
<tt>
<b><pre>db close
	[-nosync]
</pre></b>
<b>Description(db close)</b>
<p>The <i>db</i> <b>close</b> command flushes any cached database information to
disk, closes any open cursors, frees any allocated resources, and closes
any underlying files.  Because key/data pairs are cached in memory, failing
to sync the file with the <i>db</i> <b>close</b> or <i>db</i> <b>sync</b> command may
result in inconsistent or lost information.</p>
<p>The options are as follows:</p>
<br>
<b>-nosync</b><ul compact><li>Do not flush cached information to disk.
<p>The -nosync flag is a dangerous option. It should only be set if the
application is doing logging (with transactions) so that the database is
recoverable after a system or application crash, or if the database is
always generated from scratch after any system or application crash.</p>
<p>It is important to understand that flushing cached information to disk
only minimizes the window of opportunity for corrupted data.  Although
unlikely, it is possible for database corruption to happen if a system or
application crash occurs while writing data to the database. To ensure
that database corruption never occurs, applications must either use
transactions and logging with automatic recovery, use logging and
application-specific recovery, or edit a copy of the database; and after
all applications using the database have successfully called
<i>db</i> <b>close</b>, atomically replace the original database with the
updated copy.</p></ul>
<br>
<p>After <i>db</i> <b>close</b> has been called, regardless of its return, the DB
handle may not be accessed again.</p>
<p>The <i>db</i> <b>close</b> command returns 0 on success, and in the case of error, a Tcl error
is thrown.</p>
</tt>
<table width="100%"><tr><td><br></td><td align=right>
<a href="../api_tcl/api_tcl.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
</td></tr></table>
<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
</body>
</html>