1<?xml version="1.0" encoding="UTF-8" standalone="no"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 6 <title>db close</title> 7 <link rel="stylesheet" href="apiReference.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> 9 <link rel="start" href="index.html" title="Berkeley DB TCL API Reference" /> 10 <link rel="up" href="tclapi.html" title="Chapter 1. Berkeley DB Tcl APIs" /> 11 <link rel="prev" href="tclapi.html" title="Chapter 1. Berkeley DB Tcl APIs" /> 12 <link rel="next" href="db_count.html" title="db count" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center"><span class="emphasis"><em>db</em></span> close</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="tclapi.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 1. 23 Berkeley DB Tcl APIs 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="db_count.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="db_close"></a><span class="emphasis"><em>db</em></span> close</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">db close 39 [-nosync] </pre> 40 <p> 41 The <span class="emphasis"><em>db</em></span> <span class="bold"><strong>close</strong></span> 42 command flushes any cached database information to disk, closes any 43 open cursors, frees any allocated resources, and closes any underlying 44 files. Because key/data pairs are cached in memory, failing to sync 45 the file with the <span class="emphasis"><em>db</em></span> <span class="bold"><strong>close</strong></span> or <span class="emphasis"><em>db</em></span> <span class="bold"><strong>sync</strong></span> command may result in inconsistent or lost 46 information. 47 </p> 48 <p> 49 The options are as follows: 50 </p> 51 <div class="itemizedlist"> 52 <ul type="disc"> 53 <li> 54 <p> 55 <span class="bold"><strong>-nosync</strong></span> 56 </p> 57 <p> 58 Do not flush cached information to disk. 59 </p> 60 <p> 61 The <code class="literal">-nosync</code> flag is a dangerous option. It should only be set if the 62 application is doing logging (with transactions) so that the database 63 is recoverable after a system or application crash, or if the database 64 is always generated from scratch after any system or application 65 crash. 66 </p> 67 <p> 68 It is important to understand that flushing cached information to disk 69 only minimizes the window of opportunity for corrupted data. Although 70 unlikely, it is possible for database corruption to happen if a system 71 or application crash occurs while writing data to the database. To 72 ensure that database corruption never occurs, applications must either 73 use transactions and logging with automatic recovery, use logging and 74 application-specific recovery, or edit a copy of the database; and 75 after all applications using the database have successfully called 76 <span class="emphasis"><em>db</em></span> <span class="bold"><strong>close</strong></span>, 77 atomically replace the original database with the updated copy. 78 </p> 79 </li> 80 </ul> 81 </div> 82 <p> 83 After <span class="emphasis"><em>db</em></span> <span class="bold"><strong>close</strong></span> 84 has been called, regardless of its return, the DB handle may not be 85 accessed again. 86 </p> 87 <p> 88 The <span class="emphasis"><em>db</em></span> <span class="bold"><strong>close</strong></span> 89 command returns 0 on success, and in the case of error, a Tcl error is 90 thrown. 91 </p> 92 </div> 93 <div class="navfooter"> 94 <hr /> 95 <table width="100%" summary="Navigation footer"> 96 <tr> 97 <td width="40%" align="left"><a accesskey="p" href="tclapi.html">Prev</a> </td> 98 <td width="20%" align="center"> 99 <a accesskey="u" href="tclapi.html">Up</a> 100 </td> 101 <td width="40%" align="right"> <a accesskey="n" href="db_count.html">Next</a></td> 102 </tr> 103 <tr> 104 <td width="40%" align="left" valign="top">Chapter 1. 105 Berkeley DB Tcl APIs 106 </td> 107 <td width="20%" align="center"> 108 <a accesskey="h" href="index.html">Home</a> 109 </td> 110 <td width="40%" align="right" valign="top"> <span class="emphasis"><em>db</em></span> count</td> 111 </tr> 112 </table> 113 </div> 114 </body> 115</html> 116