clienc connect
/usr/local/mongodb/bin/mongo ip:port
/usr/local/mongodb/bin/mongo ip:port/dbname
2. list db
show dbs
3. switch to db
use [dbname]
4.list tables
show tables
5. select one row
db.[table name].findOne()
6. select * from user where level = 2
db.user.find( { "level" : 2 } );
7. select * from user where level = 2 and server = "00"
db.user.find( { "level" : 2 , "server" : "00" } )
8. select * from user where level >= 2
db.user.find ( { "level" : { "$gte" : 2 } } );
9. select * from user where level >=2 and level <=5
db.user.find ( { "level" : { "$gte" : 2 , "$lte" : 5 } } );
10. select * from user where level >=2 and level <=5 limit 3
db.user.find ( { "level" : { "$gte" : 2 , "$lte" : 5 } } ).limit(3);
11. select name, level from user;
db.user.find( {} , {"name" : 1 , "level": 1 } );
沒有留言:
張貼留言