位置: 编程技术 - 正文

mongodb与mysql命令详细对比(mongodb mysql配合使用)

编辑:rootadmin
传统的关系数据库一般由数据库(database)、表(table)、记录(record)三个层次概念组成,MongoDB是由数据库(database)、集合(collection)、文档对象(document)三个层次组成。MongoDB对于关系型数据库里的表,但是集合中没有列、行和关系概念,这体现了模式自由的特点。

推荐整理分享mongodb与mysql命令详细对比(mongodb mysql配合使用),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:mongodb与mysql区别(超详细),mongodb和mysql性能对比,mongodb和mysql结合,mongodb mysql配合使用,mysql+mongodb,mongodb和mysql结合,mongodb与mysql相比的优缺点,mongodb和mysql结合,内容如对您有帮助,希望把文章链接给更多的朋友!

MySQL

mongodb与mysql命令详细对比(mongodb mysql配合使用)

MongoDB

说明

mysqld

mongod

服务器守护进程

mysql

mongo

客户端工具

mysqldump

mongodump

逻辑备份工具

mysql

mongorestore

逻辑恢复工具

db.repairDatabase()

修复数据库

mysqldump

mongoexport

数据导出工具

source

mongoimport

数据导入工具

grant * privileges on *.* to …

Db.addUser()

Db.auth()

新建用户并权限

show databases

show dbs

显示库列表

Show tables

Show collections

显示表列表

Show slave status

Rs.status

查询主从状态

Create table users(a int, b int)

db.createCollection("mycoll", {capped:true,

size:}) 另:可隐式创建表。

创建表

Create INDEX idxname ON users(name)

db.users.ensureIndex({name:1})

创建索引

Create INDEX idxname ON users(name,ts DESC)

db.users.ensureIndex({name:1,ts:-1})

创建索引

Insert into users values(1, 1)

db.users.insert({a:1, b:1})

插入记录

Select a, b from users

db.users.find({},{a:1, b:1})

查询表

Select * from users

db.users.find()

查询表

Select * from users where age=

db.users.find({age:})

条件查询

Select a, b from users where age=

db.users.find({age:},{a:1, b:1})

条件查询

select * from users where age<

db.users.find({'age':{$lt:}})

条件查询

select * from users where age> and age<=

db.users.find({'age':{$gt:,$lte:}})

条件查询

select * from users where a=1 and b='q'

db.users.find({a:1,b:'q'})

条件查询

select * from users where a=1 or b=2

db.users.find( { $or : [ { a : 1 } , { b : 2 } ] } )

条件查询

select * from users limit 1

db.users.findOne()

条件查询

select * from users where name like "%Joe%"

db.users.find({name:/Joe/})

模糊查询

select * from users where name like "Joe%"

db.users.find({name:/^Joe/})

模糊查询

select count(1) from users

Db.users.count()

获取表记录数

select count(1) from users where age>

db.users.find({age: {'$gt': }}).count()

获取表记录数

select DISTINCT last_name from users

db.users.distinct('last_name')

去掉重复值

select * from users ORDER BY name

db.users.find().sort({name:-1})

排序

select * from users ORDER BY name DESC

db.users.find().sort({name:-1})

排序

EXPLAIN select * from users where z=3

db.users.find({z:3}).explain()

获取存储路径

update users set a=1 where b='q'

db.users.update({b:'q'}, {$set:{a:1}}, false, true)

更新记录

update users set a=a+2 where b='q'

db.users.update({b:'q'}, {$inc:{a:2}}, false, true)

更新记录

delete from users where z="abc"

db.users.remove({z:'abc'})

删除记录

db. users.remove()

删除所有的记录

drop database IF EXISTS test;

use test

db.dropDatabase()

删除数据库

drop table IF EXISTS test;

db.mytable.drop()

删除表/collection

db.addUser(‘test', 'test')

添加用户

readOnly-->false

db.addUser(‘test', 'test', true)

添加用户

readOnly-->true

db.addUser("test","test")

更改密码

db.system.users.remove({user:"test"})

或者db.removeUser('test')

删除用户

use admin

超级用户

db.auth(‘test', ‘test')

用户授权

db.system.users.find()

查看用户列表

show users

查看所有用户

db.printCollectionStats()

查看各collection的状态

db.printReplicationInfo()

查看主从复制状态

show profile

查看profiling

db.copyDatabase('mail_addr','mail_addr_tmp')

拷贝数据库

db.users.dataSize()

查看collection数据的大小

db. users.totalIndexSize()

查询索引的大小

mongodb语法MongoDB的好处挺多的,比如多列索引,查询时可以用一些统计函数,支持多条件查询,但是目前多表查询是不支持的,可以想办法通过数据冗余来解决多表查询的问题。MongoDB对数据的操作很丰富,下面做一些举例说明,内容大部分来自官方文档,另外有部分为自己理解。查询colls所有数据db.colls.find() //select * from colls 通过指定条件查询db.colls.find({‘last_name': ‘Smith'});//select * from colls where last_name='Smith' 指定多条件查询db.colls.find( { x : 3, y : “foo” } );//select * from colls where x=3 and y='foo'指定条件范围查询db.colls.find({j: {$ne: 3}, k: {$gt: } });//select * from colls where j!=3 and k>查询不包括某内容db.colls.find({}, {a:0});//查询除a为0外的所有数据支持<, <=, >, >=查询,需用符号替代分别为$lt,$lte,$gt,$gtedb.colls.find({ “field” : { $gt: value } } ); db.colls.find({ “field” : { $lt: value } } ); db.colls.find({ “field” : { $gte: value } } );db.colls.find({ “field” : { $lte: value } } );也可对某一字段做范围查询db.colls.find({ “field” : { $gt: value1, $lt: value2 } } );不等于查询用字符$nedb.colls.find( { x : { $ne : 3 } } );in查询用字符$indb.colls.find( { “field” : { $in : array } } );db.colls.find({j:{$in: [2,4,6]}});not in查询用字符$nindb.colls.find({j:{$nin: [2,4,6]}});取模查询用字符$moddb.colls.find( { a : { $mod : [ , 1 ] } } )// where a % == 1$all查询db.colls.find( { a: { $all: [ 2, 3 ] } } );//指定a满足数组中任意值时$size查询db.colls.find( { a : { $size: 1 } } );//对对象的数量查询,此查询查询a的子对象数目为1的记录$exists查询db.colls.find( { a : { $exists : true } } ); // 存在a对象的数据db.colls.find( { a : { $exists : false } } ); // 不存在a对象的数据$type查询$type值为 据的类型值db.colls.find( { a : { $type : 2 } } ); // 匹配a为string类型数据db.colls.find( { a : { $type : } } ); // 匹配a为int类型数据使用正则表达式匹配db.colls.find( { name : /acme.*corp/i } );//类似于SQL中like内嵌对象查询db.colls.find( { “author.name” : “joe” } );1.3.3版本及更高版本包含$not查询db.colls.find( { name : { $not : /acme.*corp/i } } );db.colls.find( { a : { $not : { $mod : [ , 1 ] } } } );sort()排序db.colls.find().sort( { ts : -1 } );//1为升序2为降序limit()对限制查询数据返回个数db.colls.find().limit()skip()跳过某些数据db.colls.find().skip()snapshot()快照保证没有重复数据返回或对象丢失count()统计查询对象个数db.students.find({‘address.state' : ‘CA'}).count();//效率较高db.students.find({‘address.state' : ‘CA'}).toArray().length;//效率很低group()对查询结果分组和SQL中group by函数类似distinct()返回不重复值

mongoDB分页的两种方法(图例) mongoDB分页的两种方法mongoDB的分页查询是通过limit(),skip(),sort()这三个函数组合进行分页查询的下面这个是我的测试数据db.test.find().sort({"age":1});第一种方

1亿条记录的MongoDB数据库随机查询性能测试 mongdb性能压力测试,随机查询,数据量1亿条记录操作系统centos6.4x位从测试结果看,当mongodb将数据全部载入到内存后,查询速度根据文档的大小,性能

Mongodb 忘记密码的解决办法 下午刚设置的密码,当时忘记保存,晚上去吃了个晚饭回来就忘记了。研究了一会发现也不难,不过网上没有直接搜到就记录一下,按照以下步骤操作即

标签: mongodb mysql配合使用

本文链接地址:https://www.jiuchutong.com/biancheng/320211.html 转载请保留说明!

上一篇:MongoDB常用命令小结(mongodb操作)

下一篇:mongoDB分页的两种方法(图例)(mongotemplate 分页查询)

  • 自然人税收管理系统残疾人申报
  • 一般纳税人开具的普票可以抵扣吗
  • 企业税申报的三种方式
  • 标书费没有发票收据可以入帐吗
  • 个税专项附加继续教育
  • 金税盘数据迁移失败
  • 预付款类发票可抵扣吗
  • 变更法人代表要查征信吗
  • 机票行程单丢了可以重新打吗
  • 企业所得税完税凭证在哪里打印
  • 国外包裹退回费用
  • 应收账款确认无法收回分录
  • 购置房屋
  • 汇票退回会计分录怎么写
  • 材料验收入库款项尚未支付
  • 材料溢价分录
  • 销售应税消费品应交的消费税
  • 仪器设备校验记录表
  • 房地产行业增值税筹划
  • 将自建的厂房对外转让需要缴纳增值税吗
  • 发票限额是含税还是不含
  • 工会筹备金交给谁
  • 注册资本金印花税减半征收
  • 境外所得税收抵免政策
  • 无偿提供服务需要交增值税吗
  • 子公司借款给母公司要交税吗
  • 原材料账户可以按什么进行明细核算
  • 与工程有关的差旅费是否可以计入在建工程呢?
  • 研发费用的
  • 利息收入是否缴纳印花税
  • 预缴地实现的月销售额未超过
  • 应收账款产生的利息分录
  • w10电脑很卡
  • 企业财政拨款所得免税吗
  • 最新的小微企业平均寿命
  • 怎么做才能让电脑里自动翻译成中文
  • 有什么好方法可以让小孩子少吃糖
  • 赠品不开发票合理么
  • 修改注册表限制cpu速度
  • 房地产企业怎么结转成本
  • 发票开了对方未付款
  • 计算应缴房产税的公式
  • 应付票据核算的票据包括
  • 政府机关出租房屋要交税吗
  • 会计如何建账做账
  • 固定资产非正常损失进项税
  • thinkphp框架安装
  • thinkphp框架结构
  • php实现自动识别的方法
  • 前端基础知识总结
  • “php”
  • excel&命令
  • 非税收入定额票据可以报销吗去什么地方报销
  • 与下级往来账户贷方核算的内容有
  • 物业会计账务处理大全
  • 用友t3资产负债表怎么生成季报
  • 现代服务业进项抵扣新政策
  • 服务不动产和无形资产本期数,第19栏
  • 期初建帐
  • 财税2009年87号文废止
  • linux使用pip
  • ubuntu修改ip地址方法
  • 笔记本摄像头摄像
  • linux允许ping
  • 安装win 7系统
  • win7系统运行怎么打开
  • win8怎么开机不用密码
  • unity粒子制作ui特效
  • dos命令语法
  • js中密码由字母和数字组成,长度为4-20
  • nodejs xhr
  • oracle中提取日期时间的特定部分
  • vue插件使用
  • unity 几种触发事件
  • 个体户注销税盘需要公章吗
  • 芜湖买房退契税在哪里退
  • 企业年报通怎么注销
  • 出口退税申报时闿
  • 火车报销凭证丢了还能退款吗
  • 成都国税工勤人员待遇
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设