Berkeley DB: DbEnv::dbremove
Description: Berkeley DB: An embedded database programmatic toolkit.
Keywords: embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++

### DbEnv::dbremove |

`

###

    #include <db_cxx.h>

    int
    DbEnv::dbremove(DbTxn *txnid,
        const char *file, const char *database, u_int32_t flags);

### Description: DbEnv::dbremove

The DbEnv::dbremove method removes the database specified by the file and database parameters. If no database is specified, the underlying file represented by file is removed, incidentally removing all of the databases it contained.

Applications should never remove databases with open Db handles, or in the case of removing a file, when any database in the file has an open handle. For example, some architectures do not permit the removal of files with open system handles. On these architectures, attempts to remove databases currently in use by any thread of control in the system may fail.

The DbEnv::dbremove method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success.

### Parameters

database
  The database parameter is the database to be removed.
file
  The file parameter is the physical file which contains the database(s) to be removed.

  When using a Unicode build on Windows (the default), the file argument will be interpreted as a UTF-8 string, which is equivalent to ASCII for Latin characters.

flags
  The flags parameter must be set to 0 or the following value:
  DB_AUTO_COMMIT
    Enclose the DbEnv::dbremove call within a transaction. If the call succeeds, changes made by the operation will be recoverable. If the call fails, the operation will have made no changes.
txnid
  If the operation is part of an application-specified transaction, the txnid parameter is a transaction handle returned from DbEnv::txn_begin; if the operation is part of a Berkeley DB Concurrent Data Store group, the txnid parameter is a handle returned from DbEnv::cdsgroup_begin; otherwise NULL. If no transaction handle is specified, but the DB_AUTO_COMMIT flag is specified, the operation will be implicitly transaction protected.

### Environment Variables

The environment variable DB_HOME may be used as the path of the database environment home.

DbEnv::dbremove is affected by any database directory specified using the DbEnv::set_data_dir method, or by setting the "set_data_dir" string in the environment's DB_CONFIG file.

### Errors

The DbEnv::dbremove method may fail and throw DbException, encapsulating one of the following non-zero errors, or return one of the following non-zero errors:

EINVAL
  If DbEnv::dbremove called before DbEnv::open was called; or if an invalid flag value or parameter was specified.

ENOENT
  The file or directory does not exist.

If a transactional database environment operation was selected to resolve a deadlock, the DbEnv::dbremove method will fail and either return DB_LOCK_DEADLOCK or throw a DbDeadlockException exception.

If a Berkeley DB Concurrent Data Store database environment configured for lock timeouts was unable to grant a lock in the allowed time, the DbEnv::dbremove method will fail and either return DB_LOCK_NOTGRANTED or throw a DbLockNotGrantedException exception.

### Class

DbEnv

### See Also

Database Environments and Related Methods`

Copyright (c) 1996,2007 Oracle. All rights reserved.