June 2014
Intermediate to advanced
696 pages
38h 52m
English
MongoDB doesn’t provide a command in the shell to explicitly create databases. Instead, you can simply use use <new_database_name> to create a new database handle. Keep in mind that the new database will not actually be saved until you add a collection to it. For example, the following commands create a new database named newDB and then add a collection named newCollection to it:
use newDBdb.createCollection("newCollection")
To verify that the new database exists, you can then use show dbs, as shown in Figure 12.5.
Figure 12.5 Creating a new database in the MongoDB shell.
Read now
Unlock full access