图解Mongo Shell的使用
mongo shell是一个MongoDB的交互式JavaScript接口。您可以使用mongo shell来查询和更新数据以及执行管理操作。
本篇经验将和大家介绍Mongo Shell的使用方法,希望对大家的工作和学习有所帮助!
方法/步骤
打开cmd命令行,输入mongo,就可以进入mongo Shell,如下图所示:
输入cls命令清屏,开始常用命令体验,如下图所示:
show dbs
输入show dbs,显示当前所有数据库,这里显示了默认的数据库,如下图所示:
use 数据库名
这个命令可以切换到指定的数据库,如果切换到了不存在的数据库,当在这个数据库存储数据时,就会自动创建这个数据库。
我们输入show school,切换到school数据库,这里返回了switched to db school,如下图所示:
show collections
这个命令可以显示当前数据库下的所有集合,我们输入show collections试一下,可以发现,students数据库下什么集合都没有,如下图所示:
db.collection.insert()
这个方法把文档插入到集合中,我们输入db.student.insert({name:"hushiyun",age:24}),将一条数据(文档)插入。这里返回的结果显示已经插入了一条文档,如下图所示:
db.collection.find()
这个方法可以查询当前集合中所有的文档,我们输入进去查询一下,这样就查到了我们刚才插入的那一条文档,如下图所示:
图解Mongo Shell的使用的更多相关文章
- MongoDB error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js(转)
rror: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js 一般这种情况就是:自己指定的数据库,所以不能.自动加 ...
- 常见的mongo shell命令
启动mongo shell 在windows下,双击mongo.exe可以启动mongo shell 查询库.表及选择库 查询所有库命令: show dbs 应用某一个db use jxs_datab ...
- MongoDB - The mongo Shell, mongo Shell Quick Reference
mongo Shell Command History You can retrieve previous commands issued in the mongo shell with the up ...
- MongoDB - The mongo Shell, Data Types in the mongo Shell
MongoDB BSON provides support for additional data types than JSON. Drivers provide native support fo ...
- MongoDB - The mongo Shell, Write Scripts for the mongo Shell
You can write scripts for the mongo shell in JavaScript that manipulate data in MongoDB or perform a ...
- MongoDB - The mongo Shell, Access the mongo Shell Help
In addition to the documentation in the MongoDB Manual, the mongo shell provides some additional inf ...
- MongoDB - The mongo Shell, Configure the mongo Shell
Customize the Prompt You may modify the content of the prompt by setting the variable prompt in the ...
- MongoDB - Introduction of the mongo Shell
Introduction The mongo shell is an interactive JavaScript interface to MongoDB. You can use the mong ...
- couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
当直接执行./mongo 出现这样的提示:couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145 解决: ...
随机推荐
- mysql类似oracle rownum写法
rownum是oracle才有的写法,rownum在oracle中可以用于取第一条数据,或者批量写数据时限定批量写的数量等 mysql取第一条数据写法 SELECT * FROM t order by ...
- Python数据类型详解——字典
Python数据类型详解--字典 引子 已经学习了列表,现在有个需求--把公司每个员工的姓名.年龄.职务.工资存到列表里,你怎么存? staff_list = [ ["Kwan", ...
- CF 462 C. A Twisty Movement 分段想 线段树 或 dp
题意 有一个只包含1和2的序列,试翻转一个区间,使得结果中非连续非递减数列最长. 思路 一. 作出1的前缀计数和为cnt1,2的后缀计数和为cnt2, 由于要找出[1,1,1][2,2,2][1,1, ...
- codeforces 701 D. As Fast As Possible(数学题)
题目链接:http://codeforces.com/problemset/problem/701/D 题意:给你n个人,每个人走路的速度v1,有一辆车速度为v2,每次可以载k个人,总路程为l,每个人 ...
- Erlang模块gen_tcp翻译
概述 TCP/IP套接字接口 描述 gen_tcp模块提供了使用TCP / IP协议与套接字进行通信的功能. 以下代码片段提供了一个客户端连接到端口5678的服务器的简单示例,传输一个二进制文件并关闭 ...
- Java web的基本概念
概念一直是学习计算机软件开发中经常遇到的问题,也是软件行业最喜欢创造的东西.很多时候,学习计算机软件开发遇到困难都是因为对某些概念的不理解,而不是因为技术本身有多么复杂.Java Web作为Java ...
- window下载安装maven
Maven官网下载地址:https://maven.apache.org/download.cgi,这里我们下载zip包即可 解压到安装目录下 新建环境变量MAVEN_HOME,复制Maven安装 ...
- Matlab2016b破解安装教程——超详细
一.MATLAB是什么 MATLAB :是美国MathWorks公司出品的商业数学软件,用于算法开发.数据可视化.数据分析以及数值计算的高级技术计算语言和交互式环境,主要包括MATLAB和Simuli ...
- <%@ include %>导入的文件乱码
如: <% String ss = (String) session.getAttribute("username"); if (ss == null || ss == &q ...
- flex布局笔记整理
flex布局笔记整理 了解-webkit-box 利用postcss进行css代码的向后兼容时,display:flex兼容后的代码常会带有display:-webkit-box. 部分移动端内核较低 ...