Home  >  Article  >  Database  >  MongoDB 学习笔记一

MongoDB 学习笔记一

WBOY
WBOYOriginal
2016-06-07 16:31:15964browse

#查看数据库show dbs;#查看当前数据库db;#查看集合/表 show collections;show tables; #为了兼容mysql习惯#给user集合插入一条JSON数据db.user.insert({name: 'user1', age: 25});#查询数据db.user.find();#删除集合数据db.user.remove();# 把"name"为"user2

#查看数据库
show dbs;
#查看当前数据库
db;
#查看集合/表         
show collections;
show tables; #为了兼容mysql习惯
#给user集合插入一条JSON数据
db.user.insert({name: 'user1', age: 25});
#查询数据
db.user.find();
#删除集合数据
db.user.remove();
# 把"name"为"user2"修改为"user200"
db.user.update({name:'user2'}, {$set: {name:'user200'}});
#把"name"为"user200"的"sex"修改为"male"如果不存在,则增加
db.user.update({name:'user200'}, {$set:{sex:'male'}});
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:MongoDB 学习笔记二Next article:The Most Popular Pub Names