MongoDB学习——命令操作

MongoDB【MongoDB命令、CRUD操作 】(二)-全面详解(学习总结---从入门到深化) 阅读详情

【转自:http://hi.baidu.com/jadmin/blog/item/c734ab589cc52bc69d82043b.html】

一、DB Shell数据库操作

数据库

1、Help查看命令提示
help
db.help();
db.yourColl.help();
db.youColl.find().help();
rs.help();

2、切换/创建数据库
>use yourDB;
当创建一个集合(table)的时候会自动创建当前数据库

3、查询所有数据库
show dbs;

4、删除当前使用数据库
db.dropDatabase();

5、从指定主机上克隆数据库
db.cloneDatabase(“127.0.0.1”);
将指定机器上的数据库的数据克隆到当前数据库

6、从指定的机器上复制指定数据库数据到某个数据库
db.copyDatabase("mydb", "temp", "127.0.0.1");
将本机的mydb的数据复制到temp数据库中

7、修复当前数据库
db.repairDatabase();

8、查看当前使用的数据库
db.getName();
db;
db和getName方法是一样的效果,都可以查询当前使用的数据库

9、显示当前db状态
db.stats();

10、当前db版本
db.version();

11、查看当前db的链接机器地址

db.getMongo();

Collection聚集集合

1、创建一个聚集集合(table)
db.createCollection(“collName”, {size: 20, capped: 5, max: 100});

2、得到指定名称的聚集集合(table)
db.getCollection("account");

3、得到当前db的所有聚集集合
db.getCollectionNames();

4、显示当前db所有聚集索引的状态
db.printCollectionStats();

用户相关

1、添加一个用户
db.addUser("name");
db.addUser("userName", "pwd123", true);
添加用户、设置密码、是否只读

2、数据库认证、安全模式
db.auth("userName", "123123");

3、显示当前所有用户
show users;

4、删除用户
db.removeUser("userName");

其他

1、查询之前的错误信息
db.getPrevError();

2、清除错误记录
db.resetError();

二、Collection聚集集合操作

查看聚集集合基本信息

1、查看帮助
db.yourColl.help();


2、查询当前集合的数据条数
db.yourColl.count();

3、查看数据空间大小
db.userInfo.dataSize();

4、得到当前聚集集合所在的db
db.userInfo.getDB();

5、得到当前聚集的状态
db.userInfo.stats();

6、得到聚集集合总大小
db.userInfo.totalSize();

7、聚集集合储存空间大小
db.userInfo.storageSize();

8、Shard版本信息
db.userInfo.getShardVersion()

9、聚集集合重命名
db.userInfo.renameCollection("users");
将userInfo重命名为users

10、删除当前聚集集合
db.userInfo.drop();

聚集集合查询
1、查询所有记录
db.userInfo.find();
相当于:select * from userInfo;
默认每页显示20条记录,当显示不下的情况下,可以用it迭代命令查询下一页数据。注意:键入it命令不能带“;”
但是你可以设置每页显示数据的大小,用DBQuery.shellBatchSize = 50;这样每页就显示50条记录了。

2、查询去掉后的当前聚集集合中的某列的重复数据
db.userInfo.distinct("name");
会过滤掉name中的相同数据
相当于:select distict name from userInfo;

3、查询age = 22的记录
db.userInfo.find({"age": 22});
相当于: select * from userInfo where age = 22;

4、查询age > 22的记录
db.userInfo.find({age: {$gt: 22}});
相当于:select * from userInfo where age > 22;

5、查询age < 22的记录
db.userInfo.find({age: {$lt: 22}});
相当于:select * from userInfo where age < 22;

6、查询age >= 25的记录
db.userInfo.find({age: {$gte: 25}});
相当于:select * from userInfo where age >= 25;

7、查询age <= 25的记录
db.userInfo.find({age: {$lte: 25}});

8、查询age >= 23 并且 age <= 26
db.userInfo.find({age: {$gte: 23, $lte: 26}});

9、查询name中包含 mongo的数据
db.userInfo.find({name: /mongo/});
//相当于%%
select * from userInfo where name like ‘%mongo%’;

10、查询name中以mongo开头的
db.userInfo.find({name: /^mongo/});
select * from userInfo where name like ‘mongo%’;

11、查询指定列name、age数据
db.userInfo.find({}, {name: 1, age: 1});
相当于:select name, age from userInfo;
当然name也可以用true或false,当用ture的情况下河name:1效果一样,如果用false就是排除name,显示name以外的列信息。

12、查询指定列name、age数据, age > 25
db.userInfo.find({age: {$gt: 25}}, {name: 1, age: 1});
相当于:select name, age from userInfo where age > 25;

13、按照年龄排序
升序:db.userInfo.find().sort({age: 1});
降序:db.userInfo.find().sort({age: -1});

14、查询name = zhangsan, age = 22的数据
db.userInfo.find({name: 'zhangsan', age: 22});
相当于:select * from userInfo where name = ‘zhangsan’ and age = ‘22’;

15、查询前5条数据
db.userInfo.find().limit(5);
相当于:select top 5 * from userInfo;

16、查询10条以后的数据
db.userInfo.find().skip(10);
相当于:select * from userInfo where id not in (
select top 10 * from userInfo
);

17、查询在5-10之间的数据
db.userInfo.find().limit(10).skip(5);
可用于分页,limit是pageSize,skip是第几页*pageSize

18、or与 查询
db.userInfo.find({$or: [{age: 22}, {age: 25}]});
相当于:select * from userInfo where age = 22 or age = 25;

19、查询第一条数据
db.userInfo.findOne();
相当于:select top 1 * from userInfo;
db.userInfo.find().limit(1);

20、查询某个结果集的记录条数
db.userInfo.find({age: {$gte: 25}}).count();
相当于:select count(*) from userInfo where age >= 20;

21、按照某列进行排序
db.userInfo.find({sex: {$exists: true}}).count();
相当于:select count(sex) from userInfo;

索引

1、创建索引
db.userInfo.ensureIndex({name: 1});
db.userInfo.ensureIndex({name: 1, ts: -1});

2、查询当前聚集集合所有索引
db.userInfo.getIndexes();

3、查看总索引记录大小
db.userInfo.totalIndexSize();

4、读取当前集合的所有index信息
db.users.reIndex();

5、删除指定索引
db.users.dropIndex("name_1");

6、删除所有索引索引
db.users.dropIndexes();

修改、添加、删除集合数据
1、添加
db.users.save({name: ‘zhangsan’, age: 25, sex: true});
添加的数据的数据列,没有固定,根据添加的数据为准

2、修改
db.users.update({age: 25}, {$set: {name: 'changeName'}}, false, true);
相当于:update users set name = ‘changeName’ where age = 25;

db.users.update({name: 'Lisi'}, {$inc: {age: 50}}, false, true);
相当于:update users set age = age + 50 where name = ‘Lisi’;

db.users.update({name: 'Lisi'}, {$inc: {age: 50}, $set: {name: 'hoho'}}, false, true);
相当于:update users set age = age + 50, name = ‘hoho’ where name = ‘Lisi’;

3、删除
db.users.remove({age: 132});

4、查询修改删除
db.users.findAndModify({
    query: {age: {$gte: 25}},
    sort: {age: -1},
    update: {$set: {name: 'a2'}, $inc: {age: 2}},
    remove: true
});

db.runCommand({ findandmodify : "users",
    query: {age: {$gte: 25}},
    sort: {age: -1},
    update: {$set: {name: 'a2'}, $inc: {age: 2}},
    remove: true
});
update 或 remove 其中一个是必须的参数; 其他参数可选。

参数                                                                                              详解                                                                                       默认值
query                                                                                      查询过滤条件                                                                                       {}
sort         如果多个文档符合查询过滤条件,将以该参数指定的排列方式选择出排在首位的对象,该对象将被操作           {}
remove                                                             若为true,被选中对象将在返回前被删除                                                             N/A
update                                                                               一个 修改器对象                                                                                     N/A
new                                  若为true,将返回修改后的对象而不是原始对象。在删除操作中,该参数被忽略。                      false
fields                                                           参见Retrieving a Subset of Fields (1.5.0+)                                                            All fields
upsert                                                          创建新对象若查询结果为空。 示例 (1.5.4+)                                                             false

语句块操作
1、简单Hello World
print("Hello World!");
这种写法调用了print函数,和直接写入"Hello World!"的效果是一样的;

2、将一个对象转换成json
tojson(new Object());
tojson(new Object('a'));

3、循环添加数据
> for (var i = 0; i < 30; i++) {
    db.users.save({name: "u_" + i, age: 22 + i, sex: i % 2});
  };
这样就循环添加了30条数据,同样也可以省略括号的写法
> for (var i = 0; i < 30; i++) db.users.save({name: "u_" + i, age: 22 + i, sex: i % 2});
也是可以的,当你用db.users.find()查询的时候,显示多条数据而无法一页显示的情况下,可以用it查看下一页的信息;

4、find 游标查询
>var cursor = db.users.find();
> while (cursor.hasNext()) {
    printjson(cursor.next());
}
这样就查询所有的users信息,同样可以这样写
var cursor = db.users.find();
while (cursor.hasNext()) { printjson(cursor.next); }
同样可以省略{}号

5、forEach迭代循环
db.users.find().forEach(printjson);
forEach中必须传递一个函数来处理每条迭代的数据信息

6、将find游标当数组处理
var cursor = db.users.find();
cursor[4];
取得下标索引为4的那条数据
既然可以当做数组处理,那么就可以获得它的长度:cursor.length();或者cursor.count();
那样我们也可以用循环显示数据
for (var i = 0, len = c.length(); i < len; i++) printjson(c[i]);

7、将find游标转换成数组
> var arr = db.users.find().toArray();
> printjson(arr[2]);
用toArray方法将其转换为数组

8、定制我们自己的查询结果
只显示age <= 28的并且只显示age这列数据
db.users.find({age: {$lte: 28}}, {age: 1}).forEach(printjson);
db.users.find({age: {$lte: 28}}, {age: true}).forEach(printjson);
排除age的列
db.users.find({age: {$lte: 28}}, {age: false}).forEach(printjson);

9、forEach传递函数显示信息
db.things.find({x:4}).forEach(function(x) {print(tojson(x));});
上面介绍过forEach需要传递一个函数,函数会接受一个参数,就是当前循环的对象,然后在函数体重处理传入的参数信息。

OpenClaw Windows 最详细安装指南 Windows上养龙虾:OpenClaw完整安装教程+钉钉接入,助你养只大龙虾 阅读详情

相关推荐

【PyBind11+anaconda+opencv+windows11+cmake+wsl+vscode】从入门到跑通。构建基于opencv c++的python package

如何安装请详见上文 【PyBind11+anaconda+opencv+windows11+cmake+wsl+vscode】从入门到跑通。构建基于opencv c++的python接口_子韵如初的博客-CSDN博客w不需要安装啥x11 、 xming直接mobxterm可以搞定点击右上角的X server打开可视化服务器然后 apt install x11-apps -yxclock 搞定从mobxterm可以看到display的端口X11显示可视化的原理是就是通过X协议,类似于http对linux于w

weixin_43953700的博客 3万+

MongoDB学习(四)常用操作命令

【前言】         以下命令摘自官网截止目前2016年8月25日为止最新版3.2的部分,只作为参考,鄙人水平有限(其实我是渣渣)有的地方翻译不到位,还请海涵并指出,一定虚心学习! 【正文】 一、常用命令 命令 参考释义 help 显示基本操作命令 db.help() 显示

代码与酒 1万+

内网渗透—横向移动&IPC横移&Impacket套件&CS插件

以上便是IPC横移的知识。最后,以上仅为个人的拙见,如何有不对的地方,欢迎各位师傅指正与补充,有兴趣的师傅可以一起交流学习。

2301_76227305的博客 1898

MongoDB 学习第三课--MongoDB基本命令操作

为了方便查阅,这里将MongoDB常用命令进行了整理。 目录 一、数据库级操作 1、 查看数据库 show dbs 2、使用指定库 use dukun 3、查看所有数据集 查看当前使用的库 删除数据库 二、Collection级操作 1、新建collectiondb.createCollection("user") 2、删除collection db.user.dro...

qq_36697880的博客 809

ensp企业网综合实验(课程设计)

使用MSTP+VRRP技术实现负载均衡以及增加网络的可靠性;出口配置napt;所有用户均为自动获取IP地址;

qq_50829760的博客 1万+

学Simulink--进阶电机控制场景实例:基于Simulink的异步电机定子磁链定向控制(SFOC)仿真

本文详细介绍了基于Simulink的异步电机定子磁链定向控制(SFOC)仿真实现方法。主要内容包括:1) SFOC原理分析,突出其对转子参数不敏感的优势;2) 工业风机驱动系统的完整建模流程,涵盖主电路搭建、坐标变换、磁链观测器设计等关键步骤;3) 核心模块代码实现,包括电压模型磁链观测器和双闭环PI控制器;4) 仿真结果验证了SFOC在转速响应(0.2s)、转矩恢复(0.15s)和参数鲁棒性(转子电阻变化50%时转速波动<2%)方面的优异性能。本文为工程师提供了实用的SFOC系统开发指南,特别适用于

amy_mhd的博客 121

golang mongodb or条件_MongoDB的学习,操作命令详细介绍

mongo shellmongo shell是MongoDB的交互式JavaScript接口。 您可以使用mongo shell查询和更新数据以及执行管理操作。mongo shell作为MongoDB Server安装的一部分包含在内。 MongoDB还提供mongo shell作为独立软件包。 现在我们开始使用吧,进入mongodb的安装目录的bin目录,当然你也可以设置mongodb的环境变量...

weixin_42313675的博客 1340

IMX6ULL---从零开始移植uboot-imx

IMX6ULL---从零开始移植uboot-imx

weixin_42162924的博客 1032

MongoDB学习【三】MongoDB基本操作命令

mongo shell是MongoDB自带的一个基于JavaScript的交互式环境,用于对MongoDB数据库进行操作。进入mongo shell后,可以连接到本地MongoDB服务器,如果MongoDB服务正在运行且默认监听27017端口,则无需额外指定连接参数。在Windows环境下,通常你可以通过命令提示符(cmd)来启动MongoDB服务。首先确保已经正确设置了。如果是在开发环境中,也可以直接运行mongod服务而不作为后台进程,不过生产环境中一般不会这样做。

2301_76508397的博客 813

SerDes系列之FFE均衡技术

FFE的基本结构可以在RX侧或TX侧实现,其基本工作原理相同:它通过从同一信号源应用适当的延迟来产生多径信号,然后对它们进行线性缩放和组合以消除信道ISI。

一只豌豆象的博客 4275

大厂面经:大疆嵌入式面试题及参考答案(4万字长文:持续更新)

目录 Linux 系统调用的过程,中间发生了什么? 表格总结 Linux 中断流程,谈谈你对中断上下文的理解 中断流程 中断上下文理解 Linuxschedule()函数的原理和调用的时机 schedule()函数原理 调用时机 页表实现机制,分页的缺点? 页表机制 分页的缺点 介绍操作系统的多级反馈调度策略,时间片轮转,在项目中如何指定优先级来调度进程完成快速响应(nice命令) 多级反馈队列调度 时间片轮转 使用nice命令 聊内存分配,进程内存分配,段页式存

大模型大数据攻城狮的专栏 4176

【MongoDb学习之路】 MongoDb 基本操作命令

MongoDb 最简单、最基础的常用命令 查看已有数据库列表 show dbs 已有集合列表 show collections 删除当前数据库 db.dropDatabase 基本查询语法  db.song.find()  //查询song这个表中的所有数据 db.song.find({id:2})  查询id=2 db.song.find({id:2},{name:1})  查

AdminSong的博客 387

什么是 SAP S/4HANA 的 VDM Layering Architecture 的 CDS Hierarchy View

当涉及SAP S/4HANA的CDS Hierarchy View时,我们正在谈论一种高级数据建模技术,用于构建层次结构化的数据视图,以支持树状和分层数据的处理和分析。CDS(Core Data Services)是SAP的一种数据建模和定义语言,而CDS Hierarchy View则是CDS的一个重要组成部分,用于处理层次数据,如组织结构、产品分类、地理区域等。首先,您可以使用CDS语言创建一个新的CDS Hierarchy View,定义产品分类的层次结构。您还可以定义其他与库存相关的属性。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 398

MongoDB学习之路--命令行的命令操作

MongoDB自带了一个javascript shell,可以从命令行与MongoDB交互。 常用的命令如下: 1.查询数据库:>show dbs 2.切换数据库,如果没有指定的数据库则创建数据库:>use mongoTestDb 3.查询当前数据库中的table(聚集集合Collection):>show collections 4.创建聚集集合:>db.createCollectio

Before_Morning的专栏 845

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

MongoDB学习(四)MongoDB 日常运维操作命令

1.MongoDB 命令帮助系统在安装MongoDB后,启动服务器进程(mongod),可以通过在客户端命令mongo实现对MongoDB的管理和监控。 1.1MongoDB的命令帮助系统&gt; help    db.help()                    help on db methods    db.mycoll.help()             help on colle...

eagle89的专栏 6309

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

mongodb java 命令_MongoDB学习-->命令行增删改查&JAVA驱动操作Mongodb

大纲如下:Mongodb介绍/安装命令行增删改查操作客户端工具mongochef使用JAVA驱动操作MongodbSpring Data Mongodb框架搭建Spring Data Mongodb框架之MongoTemplateSpring Data Mongodb框架之代码连接数据库Spring Data Mongodb框架之去掉_class字段Spring Data Mongodb框架之Re...

weixin_28791139的博客 304

mongodb 输出数组字段_MongoDB的学习,操作命令详细介绍

mongo shellmongo shell是MongoDB的交互式JavaScript接口。 您可以使用mongo shell查询和更新数据以及执行管理操作。mongo shell作为MongoDB Server安装的一部分包含在内。 MongoDB还提供mongo shell作为独立软件包。 现在我们开始使用吧,进入mongodb的安装目录的bin目录,当然你也可以设置mongodb的环境变量...

weixin_39752157的博客 388

MongoDB 学习笔记3 - 命令行操作示例

1. 背景 本节使用命令行操作 mongDB。 2.知识 MongoDB是一个文档型数据库,它将数据存储在类似json的文档中。 特点: 数据以JSON方式存储,处理数据最自然,支持数组和嵌套对象。 查询也以JSON方式,支持筛选和排序,聚合。 和 关系型数据的概念对照表: MongoDB 传统的关系型数据库 database database, 相同 collectio...

张云飞Vir的专栏 333

对于mongodb在linux上的的安装与其简单命令行操作的学习回顾

今天培训主要学习了MongoDB的安装与简单操作以及关于NoSQL的一点概念性的知识,在此对所操作的MongoDB命令进行简单回顾 1.MongoDB的安装 与网上的教程无太多出入,Linux系统下直接通过终端输入命令行sudo apt-get install mongodb 即可。本人这个下载过程还是比较顺利的,没有报错。不过授课师兄提到一个他下载时装了n遍不成功的坑,最后各种百度和查资料

Club_11的博客 1170

MongoDB使用学习(二)-shell命令以及CRUD操作

这篇主要讲解与MongoDB实例进行交互的shell脚本,以及如何运用shell脚本进行数据库一般的创建,读取,插入和删除操作

mn120986的专栏 606

MongoDB学习(一)-常用操作命令

连接 语法:mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]] 参数 说明 mongodb:// 这是固定的格式,必须要指定 username:password@ 可选项,如果设置,在连接数据库服务器之后,驱动都会尝试登录这个数据库 host1 必须的指定至少一个host, host1 是这个URI唯一要填写的。它指定了要连接服务器

Holidayzz的博客 368

【MongoDB学习笔记1】MongoDB的常用命令介绍-数据库操作、集合操作、文档操作、文档分页查询、高级查询

MongoDB中默认的数据库为test,如果没有选择数据库,集合将会存放在test数据库中。选择和创建数据库,如果数据库存在则使用这个数据库,如果数据库不存在则自动创建在MongoDB中,集合只有在内容插入后才会创建,就是说,创建集合后要再插入一个文档(记录),集合才会真正创建。创建了库,但是系统中没有显示,因为先创建的库只保存在内存中,当创建集合后,系统会自动将新创建的库持久化,这时候才能查看到库有些数据库名是保留的,可以直接访问这些有特殊作用的数据库主要用来删除已经持久化的数据库。

大龄IT民工 1174

mongodb学习(-)安装及其简单的操作命令

1:下载mongodb      地址:http://www.mongodb.org/downloads  根本自己的需求下载  我下载的是window 64位的    2: 解压文件到你自己的路径  下面按照我安装的路径为准  我解压到 D:\server\mongodb 然后进入bin目录 这里面是一些命令        mongod:安装数据库 可以在mongod -- hel

淡淡忧桑 583

MongoDB 学习笔记二 CRUD操作 及常用命令

参考文档https://docs.mongodb.org/manual/core/crud-introduction/CRUDMongoDB 存储数据称为:documents,使用类似JSON的键值对方式。MongoDB documents称为BSON. documents以collections集合方式存储。集合是一类关联的documents的分组,有共享的索引。querymodificatio

猿来这样-谢厂节的博客 2231

Mongdb学习(三)MongoDB常用操作命令大全

如果你想创建一个“myTest”的数据库,先运行use myTest命令,之后就做一些操作(如:db.createCollection('user')),这样就可以创 建一个名叫“myTest”的数据库。 一、数据库常用命令 1、Help查看命令提示 [sql] view plain copy help   db.help();  

千年似流水的博客 532

【赵渝强老师】AI for Redis与MongoDB

本课程将AI大模型智能体Agent技能(Skill)体系与Redis、MongoDB两大主流NoSQL数据库深度结合,借助开源终端AI编程智能体OpenCode,基于DeepSeek大模型,教会学员如何编写、部署、调用Agent Skill,利用AI辅助完成Redis、MongoDB的运维、故障排查、集群部署、性能调优全流程实操。⚠️ 特别提示:本课程不会从零详细讲解Redis、MongoDB基础理论。

赵渝强老师CSDN博客主页 198
上一篇: MongoDB调查总结
下一篇: MongoDB入门简介
UU_Yang
博客等级 码龄23年 926粉丝 213原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址