3.10. MongoDB deletes the database

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

Page Views: 9 views

3.10.1. Grammar

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

db.dropDatabase() 

Delete the current database. The default is test. You can use the db Command to view the current database name.

3.10.2. Example

For the following example, we deleted the database runoob.

First, look at all the databases:

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

Next, we switch to the database runoob:

> use runoob switched to db runoob > 

Execute the delete command:

> db.dropDatabase() { "dropped" : "runoob", "ok" : 1 } 

Finally, we use show dbs to command whether the database has been deleted successfully:

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

3.10.3. Delete a collection

The collection deletion syntax is in the following format:

db.collection.drop() 

The following example deletes the collection site in the runoob database:

> use runoob switched to db runoob > db.createCollection("runoob") # 先创建集合,类似数据库中的表 > show tables # show collections 命令会更加准确点 runoob > db.runoob.drop() true > show tables > 
《地理信息系统原理、技术与方法》  97

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