Database Reference
In-Depth Information
Using MongoDB Databases and Collections
A MongoDB database is a namespace in which a group of collections is
kept. By default, MongoDB has a single database called local that contains
system-level collections. Although collections can be created in this
database, doing so is probably a bad idea because this collection is not
included in replication orsharding. In fact, the local database contains the
specialized collections used to manage replication and sharding.
MongoDB's on-disk representation uses the name of the database as the
name of the file along with a segment number. These are created lazily so
a database will not “exist” until its first collection is created. To see this,
try using the mongo client to switch to a database called mine from a fresh
install:
> use mine;
switched to db mine
> show databases;
local 0.078125GB
test (empty)
Notice that the local database is listed, but not the mine database.
However, after executing a createCollection command, the database
does exist:
> db.createCollection("first");
{ "ok" : 1 }
> show dbs;
local 0.078125GB
mine 0.203125GB
test (empty)
Checking the directory given at startup by dbpath also shows that the first
segment files now exist on disk:
$ ls
_tmp journal local.0 local.ns mine.0
mine.1 mine.ns
mongod.lock
Search WWH ::




Custom Search