Tags: int names error logging related SQL RDA input new is yourAfter the successful start of MongoDB, and then open a command line window input MONGO, you can do some of the database operations.Enter help to see the basic Operations Command:Show DBS: Display Database listShow Collections: Displays a collection in the current database (similar to a table in a relational database)Show Users: Show userUse Db.help (): Show database Operations Command with
1. Display Server Status: Db.serverstatus () 2. MongoDB can monitor data through profile to optimize it.
Check whether the profile function is currently turned on: Db.getprofilinglevel () returns level, value 0|1|2, meaning: 0 for off, 1 for slow command, 2 for all
Open profile function: Db.setprofilinglevel (level,slowms); #level等级. At level 1 o'clock, the slow command defaults to SLOWMS (unit ms)(that is, execution time is greater than
Tags: des style http color io using AR strong forAfter the successful start of MongoDB, and then open a command line window input MONGO, you can do some of the database operations.Enter help to see the basic Operations Command:Show DBS: Display Database listShow Collections: Displays a collection in the current database (similar to a table in a relational database)Show Users: Show userUse Db.help (): Show database Operations Command with a lot of comm
Comparison between MongoDB and MySQL commands
Traditional relational databases are generally composed of three levels: database, table, and record. MongoDB is composedDatabase, collection, and document)Three layers. MongoDB has no concept of columns, rows, and links for tables in relational databases, which reflects th
Label:MongoDB is a very popular NoSQL database management system, officially: MongoDB, I installed in localhost is the Enterprise Server version, the default installation file directory is: C:\Program files\mongodb\server\3.2\bin, click Windows+r, enter cmd, start command Prompt, go to the installation directory Every time you open command prompt you need to enter the installation directory of
column Db.userInfo.find ({sex: {$exists: true}}). Count (); Equivalent to: SELECT COUNT (Sex) from userInfo; Indexes (indexes are created and reused before they can cause efficiency problems) 1. Create an index db.userInfo.ensureIndex ({name:1}); Db.userInfo.ensureIndex ({name:1, TS:-1}); 2. Querying all indexes of the current aggregation collection db.userInfo.getIndexes (); 3. View Total index record size db.userInfo.totalIndexSize (); 4. Read all index information for the current collection
Basic database commands common database commands 1. Help Command Prompt helpdb. help (); db. yourColl. help (); db. youColl. find (). help (); rs. help (); 2. Switch to create database useyourDB. When a set (table) is created, the current database is automatically created. 3. query all databases. 4. Delete
Basic database commands common database
Getlasterror command
When writing data to a database, MongoDB does not wait for a response message by default. Use the getlasterror command to ensure that the operation has been correctly executed.
In many drivers, the getlasterror command is automatically called when you use the "Security" mode (set write concern) for saving and updating. But when this special getlasterror command is called, what actually happens. Here, we will introduce how it works
Common commands of MongoDB
First, install the database. You can use windows or linux, but linux is recommended. I use ubuntu12.04. you can download the database at the following URL, it is usually a 64-bit system. If you use a linux system, you can use the command line to install mongodb. I just use sudo apt-get install mongo
, the disadvantage is that the data inserted by the user during Mongodump operation may not be backed up.C. Fsync and lock Lock the database so that users can only use the Read feature, and then use method B to export and import data. The advantage does not need to stop the MONGO service, the disadvantage is that users cannot perform insert operations during database lock.D. Use Slavedb and use method C to lock the Slavedb, and then use method B to export and import the data. The advantage does
Label:MongoDB cluster deployment and cluster maintenance commands http://lipeng200819861126-126-com.iteye.com/blog/1919271 MongoDB Distributed cluster architecture and monitoring configuration http://freeze.blog.51cto.com/1846439/884925/ See the article: Seven, monitoring configuration : As early as the last year has appearedMongoDBand the Redis 's cacti template, which you can use to monitor your
Tags: common opd count () ... Rename using Age logs modMongoDB Common commands: After the successful start of MongoDB, and then open a command line window input MONGO, you can do some of the database operations. Show DBS: Display database list use
database name: Switch the current database, which is the same as the meaning of ms-sql insideShow Collections: Displays a collection in the current database (sim
the last operation
Db.getpreverror ()
Return error of previous operation
Db.reseterror ()
Clear Error logging
Manage commands
Db.clonedatabase (Fromhost)
Copies the current data database from another specified host. The fromhost must be in Noauth mode.
Db.copydatabase (Fromdb, Todb, Fromhost)
Copy the Fromhost Fromdb database to the TODB database of the curren
Frequently used commands and their introduction to advanced command usageOne: Add or delete to change the advanced application of the detailed description: * * * * * * * * When C1 is not in the words will be automatically created * * * Regardless of the insertion of the record will automatically give a value ID self-increment primary key unique insert and save (when the ID conflict is modified, otherwise inserted) one: ID primary key does not conflic
= new Mongo ("localhost");Get database serviceMongo m = new Mongo ("localhost", 27017);Get Database MyTestDB db = M.getdb ("mytest");Get all the table names under the MyTest databaseSetfor (String s:colls) {System.out.println (s);}Get testcollection TableDbcollection coll = db.getcollection ("testcollection");New A Basicdbobject object docBasicdbobject doc = new Basicdbobject ();Assign valueDoc.put ("name", "MongoDB");Doc.put ("type", "database");Doc
connection address of the current db. getMongo (); Help command prompt help db. help (); db. yourColl. help (); db. youColl. find (). help (); rs. help (); clone the database db from the specified host. cloneDatabase ("127.0.0.1 ");?? Clone the database data on the specified machine to the current database and copy the data from the specified machine to a database. copyDatabase ("mydb", "temp", "127.0.0.1 ″);? Copy the mydb data of the local machine to the temp database to repair the current da
copied, so each host needs to be compressed separately.
Currently, compression is the command that is released to mongod. In a partition environment, each partition should be compressed separately as a maintenance operation. (May be changed in future versions, along with other enhancements)
A set of fixed sizes cannot be compressed. (However, documents in a fixed-size set are not managed by fragments .)
Copy Group
Compress each member individually.
The ideal compression is to run on a sec
student table and specify the AGEGT;20> Db.student.find ({age:{$gt: 20}},{name:1,age:1}){"_id": ObjectId ("5740c1419bc83e10802f1cd6"), "name": "Tom", "Age": 23}{"_id": ObjectId ("5740dc369bc83e10802f1cd7"), "name": "Jerry", "Age": 30}{"_id": ObjectId ("5742263773344acd707888ba"), "name": "Gu Zenghui", "Age": 25}13. Sort by ageAscending: Db.student.find (). Sort ({age:1})Descending: Db.student.find (). Sort ({age:-1})14. Query for data with the name Jerry and age 30Db.student.find ({name: "Jerry
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.