3.12. MongoDB delete collection

发布时间 :2025-10-25 12:33:02 UTC      

In this section, we show you how to use MongoDB to delete collections.

Used in MongoDB drop() Method to delete the collection.

语法格式:

db.collection.drop()

Parameter description:

  • None

返回值

If the selected collection is successfully deleted, the drop() Method returns true Otherwise, return false .

3.12.1. Example

In the database mydb, we can first view the existing collections through the show collections command:

>use mydb
switched to db mydb
>show collections
mycol
mycol2
system.indexes
runoob
>

Then delete the collection mycol2 :

>db.mycol2.drop()
true
>

View the database again through show collections mydb Collections in:

>show collections
mycol
system.indexes
runoob
>

It can be seen from the results mycol2 The collection has been deleted.

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.