First knowledge of MongoDB

Source: Internet
Author: User

Nosql has undoubtedly become the most popular in the database industry in recent years, and Oracle has begun to develop. I am not very familiar with non-relational databases, so I am better at learning MongoDB. Regular notes are also a good habit of learning.

1. Install the database software. In fact, MongoDB (Windows version) is green. This is a very good thing. You don't have to wait for a long time to install it. On the official website (http://www.mongodb.org/downloads) can be downloaded, and then unzip to the local can be. Here I decompress it to E: \ MongoDB.

2. Data File Path. Like all databases, data storage requires a dedicated data storage directory (many folders in Windows ). There are many executable files under the bindirectory. mongod.exe is used to set the path, and its command is very simple. Here we use E: \ MongoDB \ dB as the path, so the command can be written like this: e: \ MongoDB \ bin> mongod.exe -- dbpath = E: \ MongoDB \ dB. Then there will be a lot of prompts, but these basically do not need to look:

The file is as follows:

3. The data file path can be used after it is set to OK. The executable file is cmd.exe. In this way, the prompt interface is displayed, which is as simple as operating Oracle under sqlplus. For example:

4. Basic Database Operations. The most basic operation in a database is addition, deletion, modification, and query. No matter which database you choose, if you do not have these four functions, it is a disability database. I have not seen the table concept in Mongo, but collection is similar to it. For example, there are two collections under the test database, and the foo contains the data that I inserted before. Check the following:

DB. Foo. Find (). :

According to my current understanding, database records are like XML Key values. Name is the key, Tom is the key value, and age is the key, "30" is the key value. Collection is not like a table. No matter whether Tom has a sex record or a sex column, the age column must be of the same data type, otherwise, the data type will be automatically converted during the insertion. Here Tom has no sex record. Here Jerry's age is recorded as a digital type, while Tom's age is balanced, that is, a collection represents a set of information, however, not every record is completely defined, it is a free existence.

The following is an increment: DB. foo. insert ({"name": "Obama", "Age": "50", "sex": "male", "job": "President "});

The middle line was accidentally written wrong. Sorry. As you can see, adding a record is indeed a little troublesome, because it is not to insert something into a fixed table, so you have to write the key every time, followed by the key value.

Modify dB. Foo. Update ({"name": "Obama" },{ "Nation": "USA "});

We can see that the change is thorough.

Delete operation: DB. Foo. Remove ({"Nation": "UDA "}):

The danger of this database is that the addition, deletion, and modification operations do not require commit. No more. I may be able to access relevant content in my future studies. Let's learn it slowly.

There are also a lot of powerful functions to explore. I hope that people who read this blog will like nosql and Mongo.

The command line tool in is powercmd, which is an enhancement of the Windows command line tool and is very useful. We recommend that you use it much better than the black box.

Baidu search is available for free.

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.