Tag:io use sp on data div bs cti ad
Database common commands 1, help view command prompt help db.help (); db.yourColl.help (); db.youColl.find (). Help (); Rs.help (); 2. switch/CREATE DATABASE use yourdb; when a collection (table) is created, the current database 3 is automatically created, all databases are queried show dbs;4, and the currently used database is deleted db.dropdatabase (); 5. Clone the database from the specified host db.clonedatabase ("127.0.0.1"); Cloning data from the database on the specified machine to the current database 6, copying the specified database data from the specified machine to a database db.copydatabase ("MyDB", "temp", "127.0.0.1"); Copy the MyDB data from the native to the temp database 7, fix the current database db.repairdatabase (), 8, view the currently used database db.getname (); db; The DB and GetName methods are the same effect, can query the currently used database 9, display the current DB status db.stats (), 10, the current DB version db.version (), 11, view the current DB link machine address Db.getmongo (); collection gather collection 1, create a clustered collection (table) db.createcollection ("Collname", {size:20, capped:5, Max: 100}); 2, the Aggregation set (table) db.getcollection ("account") that gets the specified name, 3, gets all the aggregation sets of the current DB db.getcollectionnames (); 4, Displays the status of all clustered indexes in the current DB db.printcollectionstats (); user-related 1, adding a user db.adduser ("name"); Db.adduser ("UserName", "pwd123", true); Add users, set passwords, read-only 2, database authentication, security mode db.Auth ("UserName", "123123"); 3, display all current user show users;4, delete user db.removeuser ("userName"); other 1, error message before query db.getpreverror (); 2, clear error logging db.reseterror ();
2. MongoDB Common Commands