首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

mongodb一些惯用query命令

2012-08-02 
mongodb一些常用query命令mongoDB的备份./mongodump -h 127.0.0.1? -d dbname -c collectionName -o bakDi

mongodb一些常用query命令

mongoDB的备份

./mongodump -h 127.0.0.1? -d dbname -c collectionName -o bakDir



mongoDB的query语句:

?

select:

?

????? db.users.find({})
?
? ? ? db.users.find({'last_name': 'Smith'})
?
?field selection:
?
? ? //只取ssn? 相当于 select ssn from db where last_name == 'Smith'
??? // retrieve ssn field for documents where last_name == 'Smith':
??? db.users.find({last_name: 'Smith'}, {'ssn': 1});

??? //除了域 thumbnail ,其他的域都取
??? // retrieve all fields *except* the thumbnail field, for all documents:
??? db.users.find({}, {thumbnail:0});

?

?

Sorting

MongoDB queries can return sorted results. To return all documents and sort by last name in ascending order, we'd query like so:

db.users.find().skip(20).limit(10);db.users.find({}, {}, 10, 20); // same as above, but less clear

?

?

热点排行