转  https://www.cnblogs.com/ssslinppp/p/6178636.html
  
1.information_schema数据库
  对于mysql和Infobright等数据库,information_schema数据库中的表都是只读的,不能进行更新、删除和插入等操作,也不能加触发器,因为它们实际只是一个视图,不是基本表,没有关联的文件。
  
2.information_schema.tables
information_schema.tables存储了数据表的元数据信息,下面对常用的字段进行介绍:
  • table_schema: 记录数据库名
  • table_name: 记录数据表名
  • engine : 存储引擎
  • table_rows: 关于表的粗略行估计;
  • data_length : 记录表的大小(单位字节);
  • index_length : 记录表的索引的大小
  • row_format: 可以查看数据表是否压缩过;
 
  
3.下面介绍几种常见的用法;

information_schema.tables信息;

  1. use information_schema;
  2. show create table tables;
  1. desc tables;

查询所有的数据库信息

  1. select distinct TABLE_SCHEMA from tables ;

查询数据库和数据表信息

显示mysql数据库下面的所有表信息:(共对比使用)
  1. use mysql;
  2. show tables;
通过information_schema.table获取数据库和数据表信息:
  1. use information_schema;
  2. select TABLE_SCHEMA ,table_name from tables where table_schema like 'mysql';

数据表大小以及索引大小

示例1:mysql.time_zone相关表
获取time_zone相关表的大小:
  1. select (sum(DATA_LENGTH) + sum(INDEX_LENGTH)) as size from tables where table_schema='mysql' and table_name like 'time_%';
 
示例2: 获取指定数据库的大小;
  1. select (sum(DATA_LENGTH) + sum(INDEX_LENGTH)) as size from tables where table_schema='mysql';

判断myisam数据表是否已压缩

  1. select distinct row_format,engine from information_schema.tables where engine='myisam';
  • Fixed: 表示已压缩;
  • Dynamic:表示未压缩;
 
  1. select row_format,engine,table_name from information_schema.tables where engine='myisam';

通过Linux指令直接获取数据库和数据表信息:

  1. mysql -uroot -pxxxx -D:表示数据库名称
  2.  
  3. -e:表示需要执行的指令:


最新文章

  1. java-正则表达式过滤标签
  2. 异常处理的解决方案 OneTrueError
  3. Snort 安装 配置 - Archlinux
  4. 使用Statement操作数据库
  5. BZOJ2432 [Noi2011]兔农
  6. vim编辑器,管道,输入输出重定向
  7. android之OptionsMenu
  8. 系统监控的工具tsar
  9. .net 配置文件 分析 EntityName 时出错
  10. TOGAF架构开发方法(ADM)之架构变更管理阶段
  11. 异常笔记--java编程思想
  12. Netty(一):入门篇
  13. IdentityServer4实战 - 基于角色的权限控制及Claim详解
  14. SpringBoot + Spring Security 学习笔记(五)实现短信验证码+登录功能
  15. Gradient Boosting, Decision Trees and XGBoost with CUDA ——GPU加速5-6倍
  16. Android : Camera之CHI API
  17. Tukey‘s test方法 异常值
  18. Hadoop中 Unable to load native-hadoop library for your platform... using builtin-java classes where applicable问题解决
  19. Spring 3.1新特性之二:@Enable*注解的源码,spring源码分析之定时任务Scheduled注解
  20. 常用包管理三类工具:dpkg、apt和aptitude

热门文章

  1. Nginx重写功能(rewrite与location)
  2. [zoj] 4178. Killing the Brute-force
  3. 2022-11-14 Acwing每日一题
  4. 【Devexpress】gridcontorl设置某个特定单元格不可编辑
  5. c# 使用委托子窗体改变父窗体控件
  6. [奶奶看了都会]ChatGPT保姆级注册教程
  7. vba 数组判断与转换
  8. 深度学习GPU加速配置方法
  9. Java程序员除了做增删改查还能干嘛?
  10. AStar寻路算法示例