To see which databases are available:
Show DBS
Switch to that library:
Use library name
Use Local
Use also has a function of "Create a Database"
Use test
To delete a database:
Db.dropdatabase ();
To view a collection:
Show collections
To create a collection:
Db.createcollection ("user");
Implicitly created, inserted directly into the collection, she will automatically create the collection
Db. user. Insert ({ID:1, Name: "Lisi"});
To delete a collection:
Db. user. Drop ();
Insert:
Db. user. Insert ({ID:1, Name: "Lisi", Sex: "1"});
Inquire:
Db. user. Find ()
Modify:
Db. user. Update ({ID:1},{name:'Lisi', Sex:'1'});
Delete:
Db. user. Remove ({name:'Lisi'});
If you insert two identical parameters at the same time, they will be overwritten by the following
Db. user. Insert ({x:2, x:3});
It's strictly case-sensitive in MongoDB.
If you want to make time a non-string form in real-world development, you can insert data by using the new date method:
Db. user. Insert ({name:'Lisi', Addtime:new Date ()});
If the direct date () is created as a string, the
If you do not want to see him print out the default generated heap of _id strings at the time of printing, we can query by the following methods:
Db. user. Find ({},{_id:0});
If _id:1 then print out the default _id
Life Thunder Dog MongoDB----MONGODB---2---common commands and tricks