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