Basic operations for MONGODB databases and collections

Source: Internet
Author: User

Non-relational database

    • command is case-sensitive; command Terminator is carriage return (unlike MySQL)
MongoDB Configuration
    • sudo service mongodb start
    • mongo
MongoDB Basic Concept
      • 集合
        A concept that corresponds to a relational database , creating a collection: db.createCollections("<集合名>") ; Deleting a collection: db.<集合名>.drop() ; getting all the collections:show collections
      • 文档
        The concept of a relational database 记录 , MongoDB's documentation, is represented by the bson loosely structured data structure of the class JSON (JSON-upgraded version)
        Inserting a document into the collection
        1. Useinsert()
        e.g.:db.<集合名>.insert([{name:"hello",email:"[email protected]"},{name:"world",email:"[email protected]"}])
        2. Use save() (note with the Insert () difference, save () when inserting data, the collection will be created automatically if the collection does not exist)
        e.g.:db.<集合名>.save([{name:"hello",email:"[email protected]"},{name:"world",email:"[email protected]"}])
      • 数据库
        1. Create a database:use <数据库名>
        2. View the currently connected database:db
        3. View all databases:show dbs
        4. Destroy the database: switch to the database that you want to destroy, and then executedb.dropDatabase()

Basic operations for MONGODB databases and collections

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.