Database-mongodb-Common Commands

Source: Internet
Author: User

command to start the database
1 mongod --dbpath C:\MongoDb\data\db -logpath C:\MongoDB\data\log\mongolog.log

Common commands for several databases

  1. use DATABASE_NAME // 创建数据库
  1. >db // 检查当前的数据库
  2. mydb
  1. >show dbs // 查询数据库列表
  2. local 0.78125GB
  3. test 0.23012GB
  1. db.dropDatabase(‘mydb‘)

Create a collectionMongoDB's db.createcollection (name, options)used to create a collection
  nameis the name of the collection to create Optionsis a document that specifies the configuration of the collection
capped boolean (optional) If true, it enables the upper bound collection. The upper bound collection is a fixed-size collection that automatically overwrites the oldest entries when it reaches its maximum size.   If you specify true, you also need to specify the size of the parameter.
autoindexid boolean (optional) If true, the index _id field is created automatically. The default value is False.
size number (optional) specifies the maximum size of the upper collection byte. If capped is true, you also need to specify this field.
Max Number Optionally, specify the maximum number of files allowed for the upper bound collection.

Show All Collections
  1. show collections
  1. >db.mycol.find()
  1. >db.mycol.find().pretty()

Delete Collection
the RDBMS WHERE clause is equivalent to MongoDBConditional query
  1. db.mycol.find({‘age‘:{$gte:20}}).pretty()

Mainly the usage of several keywords < $lt <= $lte > $gt >= $gte = Do not write! =!! = $ne

From for notes (Wiz)

Database-mongodb-Common Commands

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.