MongoDB basic Commands

Source: Internet
Author: User
Tags mongodb

MONGO using the database

Mongod Boot

Mongoimport Importing Data

Boot command: Mongod--dbpath path

--dbpath is the folder where you select the database document

In other words, MongoDB, there are real physical files, corresponding to a database, U disk can be moved. However, to use this database, the database must be turned on, and once it is stopped, the database shuts down automatically.

Link Database command: MONGO

MONGO Syntax:

Show DBS List all databases

Which database is used with the database name (if the use database does not exist, create a new database)

DB View the currently used database

Db.student.insert ({"Name": "Xiaoming", "Age": N, "Sex": "Nan"});

Student is the collection, which stores a lot of JSON

Show Collections View all collections in the current database

Db.student.find () finds all the elements in the current database that student this collection, and find can write some query criteria.

Data cannot be inserted directly into the database, only data can be inserted into the collection (collections). You do not need to create a collection, just write the syntax:

Db. Collection name. Insert ({"name": "Xiaoming"});

To delete a database:

Db.dropdatabase (); Delete current Database

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: info-contact@alibabacloud.com 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.