Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1592253
  • 博文数量: 184
  • 博客积分: 3044
  • 博客等级: 中校
  • 技术积分: 2467
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-25 15:04
文章分类

全部博文(184)

文章存档

2022年(4)

2021年(3)

2020年(1)

2019年(5)

2018年(13)

2017年(6)

2016年(10)

2015年(11)

2014年(11)

2013年(13)

2012年(23)

2011年(25)

2010年(2)

2008年(1)

2007年(5)

2006年(51)

分类: NOSQL

2017-05-17 14:02:21

今天在用shell 执行简单的mongo命令:
use test;
db.sky.count()
使用一句shell命令:echo "use test;\n db.sky.count()" |mongo 127.0.0.1:27017
时报错:
 Error: [test;
 db.sky.xount()] is not a valid database name 

没有正确执行。
使用echo -e 命令解决:
echo -e "use test;\n db.sky.count()" |mongo 127.0.0.1:27017
记录一下

打印所有表的记录数
db.getCollectionNames().forEach(function(collection){ print(collection +" "+ db[collection].count())})

 打印每一库的总记录数:
db.adminCommand('listDatabases')['databases'].forEach(function(dbn){printjson(dbn['name']);var my=db.getSisterDB(dbn['name']);printjson(my.stats()['objects'])})

打印Mysql每个表记录数
USE information_schema;
SELECT table_name,table_rows FROM TABLES WHERE TABLE_SCHEMA = 'education' ORDER BY table_rows DESC;

阅读(1370) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~