Working with Databases

    return the database name

    Returns the name of the current database as a string.

    Examples

    Show execution results

      Hide execution results

      ID

      return the database iddb._id()

      Returns the id of the current database as a string.

      Examples

      Show execution results

      1. 1

      Hide execution results

      Path

      return the path to database filesdb._path()

      Returns the filesystem path of the current database as a string.

      Show execution results

      1. /tmp/arangosh_eIJLPK/tmp-67-564247407/rocksdb/data

      Hide execution results

      return the database typedb._isSystem()

      Returns whether the currently used database is the system_ database.The system database has some special privileges and properties, for example,database management operations such as create or drop can only be executedfrom within this database. Additionally, the system_ database itselfcannot be dropped.

      Use Database

      change the current database

      Changes the current database to the database specified by name. Notethat the database specified by name must already exist.

      Changing the database might be disallowed in some contexts, for exampleserver-side actions (including Foxx).

      When performing this command from arangosh, the current credentials (usernameand password) will be re-used. These credentials might not be valid toconnect to the database specified by name. Additionally, the databaseonly be accessed from certain endpoints only. In this case, switching thedatabase might not work, and the connection / session should be closed andrestarted with different username and password credentials and/orendpoint data.

      List Databases

      return the list of all existing databasesdb._databases()

      Returns the list of all databases. This method can only be used from withinthe _system database.

      create a new databasedb._createDatabase(name, options, users)

      Creates a new database with the name specified by name.There are restrictions for database names(see DatabaseNames).

      The options attribute currently has no meaning and is reserved forfuture use.

      The optional users attribute can be used to create initial users forthe new database. If specified, it must be a list of user objects. Each userobject can contain the following attributes:

      • username: the user name as a string. This attribute is mandatory.
      • passwd: the user password as a string. If not specified, then it defaultsto an empty string.
      • active: a boolean flag indicating whether the user account should beactive or not. The default value is true.

      You can create users in a database if no initial user is specified. Switchinto the new database (username and password must be identical to the currentsession) and add or modify users with the following commands.

      Alternatively, you can specify user data directly. For example:

      1. db._createDatabase("newDB", {}, [{ username: "newUser", passwd: "123456", active: true}])

      Those methods can only be used from within the _system database.

      Drop Database

      drop an existing database

      Drops the database specified by name. The database specified byname must exist.

      Note: Dropping databases is only possible from within the system_database. The system_ database itself cannot be dropped.

      Databases are dropped asynchronously, and will be physically removed ifall clients have disconnected and references have been garbage-collected.

      Engine

      retrieve the storage engine type used by the serverdb._engine()

      Returns the name of the storage engine in use (mmfiles or rocksdb), as wellas a list of supported features (types of indexes and).

      retrieve statistics related to the storage engine (rocksdb)

      Note: Currently this only produces useful output for the RocksDB engine.