3.9. MongoDB creates a database

发布时间 : 2025-10-25 13:34:24 UTC      

Page Views: 9 views

3.9.1. Grammar

The syntax format for MongoDB to create a database is as follows:

use DATABASE_NAME 

If the database does not exist, create the database, otherwise switch to the specified database.

3.9.2. Example

For the following example, we created the database runoob:

> use runoob switched to db runoob > db runoob > 

If you want to view all databases, you can use the show dbs Command:

> show dbs admin 0.000GB config 0.000GB local 0.000GB > 

As you can see, the database we just created, runoob, is not in the database list. To display it, we need to insert some data into the runoob database.

> db.runoob.insert({"name":"菜鸟教程"}) WriteResult({ "nInserted" : 1 }) > show dbs admin 0.000GB config 0.000GB local 0.000GB runoob 0.000GB 

The default database in MongoDB is test. If you do not create a new database, the collection will be stored in the test database.

注意: In MongoDB, collections are created only after content has been inserted! That is, after the collection (data table) is created, another document (record) is inserted before the collection is really created.

《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。