1<!--$Id: open.so,v 10.18 2003/10/18 19:15:53 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: Database open</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>Access Methods</dl></b></td>
14<td align=right><a href="/am/ops.html"><img src="/images/prev.gif" alt="Prev"></a><a href="/toc.html"><img src="/images/ref.gif" alt="Ref"></a><a href="/am/opensub.html"><img src="/images/next.gif" alt="Next"></a>
15</td></tr></table>
16<p align=center><b>Database open</b></p>
17<p>The <a href="/api_c/db_open.html">DB-&gt;open</a> method opens a database, and takes five arguments:</p>
18<br>
19<b>file</b><ul compact><li>The name of the file to be opened.</ul>
20<b>database</b><ul compact><li>An optional database name.</ul>
21<b>type</b><ul compact><li>The type of database to open.  This value will be one of the four access
22methods Berkeley DB supports: DB_BTREE, DB_HASH, DB_QUEUE or DB_RECNO, or the
23special value DB_UNKNOWN, which allows you to open an existing file
24without knowing its type.</ul>
25<b>mode</b><ul compact><li>The permissions to give to any created file.</ul>
26<br>
27<p>There are a few flags that you can set to customize open:</p>
28<br>
29<b><a href="/api_c/env_open.html#DB_CREATE">DB_CREATE</a></b><ul compact><li>Create the underlying database and any necessary physical files.</ul>
30<b><a href="/api_c/env_set_flags.html#DB_NOMMAP">DB_NOMMAP</a></b><ul compact><li>Do not map this database into process memory.</ul>
31<b><a href="/api_c/db_open.html#DB_RDONLY">DB_RDONLY</a></b><ul compact><li>Treat the data base as read-only.</ul>
32<b><a href="/api_c/env_open.html#DB_THREAD">DB_THREAD</a></b><ul compact><li>The returned handle is free-threaded, that is, it can be used
33simultaneously by multiple threads within the process.</ul>
34<b><a href="/api_c/db_open.html#DB_TRUNCATE">DB_TRUNCATE</a></b><ul compact><li>Physically truncate the underlying database file, discarding all
35databases it contained. Underlying filesystem primitives are used to
36implement this flag. For this reason it is only applicable to the
37physical file and cannot be used to discard individual databases from
38within physical files.</ul>
39<b><a href="/api_c/db_set_feedback.html#DB_UPGRADE">DB_UPGRADE</a></b><ul compact><li>Upgrade the database format as necessary.</ul>
40<br>
41<table width="100%"><tr><td><br></td><td align=right><a href="/am/ops.html"><img src="/images/prev.gif" alt="Prev"></a><a href="/toc.html"><img src="/images/ref.gif" alt="Ref"></a><a href="/am/opensub.html"><img src="/images/next.gif" alt="Next"></a>
42</td></tr></table>
43<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
44</body>
45</html>
46