概述

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

下面介绍几种常见的用法;

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 information_schema -e "select TABLE_SCHEMA ,table_name from tables where table_schema like 'hsm_syslog_%'"

参数说明:
  • -D:表示数据库名称 
  • -e:表示需要执行的指令:


























【mysql元数据库】使用information_schema.tables查询数据库和数据表信息的更多相关文章

  1. (转)【mysql元数据库】使用information_schema.tables查询数据库和数据表信息 ---数据记录大小统计

    转:https://www.cnblogs.com/ssslinppp/p/6178636.html https://segmentfault.com/q/1010000007268994?_ea=1 ...

  2. mysql 基本语法学习1(数据库、数据表、数据列的操作)

    今天学习了一下mysql语法,并记录下来 1.mysql的数据库操作 /***1.操作数据库的语法 ***/ -- 1)显示所有数据库 -- show databases; -- 2)创建数据库 -- ...

  3. Mysql使用information.shema.tables查询数据库表大小

    简介: information_schema数据库中的表都是只读的,不能进行更新.删除和插入等操作,也不能加触发器,因为它们实际只是一个视图,不是基本表,没有关联的文件. 元数据描述数据的数据,用于描 ...

  4. mysql导入导出sql文件(包括数据库和数据表的操作)

    废话不多说直接开始. 在windows命令行下登录mysql,创建一个test_01数据库,创建一个user表,并插入一条数据,如下 一.导出数据库test_01 1.退出数据库,在命令行中输入 my ...

  5. MySQL 创建、删除、显示数据库、数据表

    1 创建.删除.显示数据库 -- 创建数据库 create database student_db character set utf8 collate utf8_general_ci; -- 删除数 ...

  6. mysql 关于数据库和数据表的基本操作

    -- 备注: -- .每一条mysql语句后面都需要加上半角分号 -- .可以用``符号(1键旁边的那个键)将字段名称引用起来,如`Name` -- .mysql在windows下不区分大小写,在li ...

  7. 代码收藏系列--mysql--创建数据库、数据表、函数、存储过程命令

    创建mysql数据库 CREATE DATABASE IF NOT EXISTS `database_name` DEFAULT CHARSET utf8 COLLATE utf8_general_c ...

  8. mysql / pgsql 使用sql语句查询数据库所有表注释已经表字段注释

    mysql使用sql语句查询数据库所有表注释已经表字段注释(转载)   场景: 1. 要查询数据库 "mammothcode" 下所有表名以及表注释 /* 查询数据库 ‘mammo ...

  9. MySql 查询数据库中所有表名

    查询数据库中所有表名select table_name from information_schema.tables where table_schema='csdb' and table_type= ...

随机推荐

  1. Xshell 登录 AWS CentOS 出现“所选择的用户秘钥未在远程主机上注册“,最终解决办法!

     其实就是 登录用户名错了,是 root,不是centos 也不是 ec2-user !  Xshell 连接配置界面如下 最重要是 登录授权配置 最后,登录成功! 就这么简单

  2. mysql 配置 utf8 依然乱码

    mysql 乱码问题排除方案: 1.检查数据库及数据表是不是utf8字符集 2.查看一下jdbc.properties配置的数据库url 是否配置了characterEncoding=UTF-8或者在 ...

  3. spring boot 初试,springboot入门,springboot helloworld例子

    因为项目中使用了spring boot ,之前没接触过,所以写个helloworld玩玩看,当做springboot的一个入门例子.搜索 spring boot.得到官方地址:http://proje ...

  4. [最近公共祖先] POJ 1330 Nearest Common Ancestors

    Nearest Common Ancestors Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 27316   Accept ...

  5. SQL Server 2008中查看锁信息

    ;with tran_locks as(select resource_type,db_name(resource_database_id) as db_name,resource_descripti ...

  6. JBoss集群中启用HTTPS协议

    Generate server certificate Note: If you already have certificate created then this section can be i ...

  7. select document library from certain list 分类: Sharepoint 2015-07-05 07:52 6人阅读 评论(0) 收藏

    S using System; using Microsoft.SharePoint; namespace Test { class ConsoleApp { static void Main(str ...

  8. JVM-程序编译与代码早期(编译期)优化

    早期(编译期)优化 一.Javac编译器 1.Javac的源代码与调试 Javac的源代码放在JDK_SRC_HOME/langtools/src/shares/classes/com/sun/too ...

  9. understanding Nhibernate Hilo

    http://stackoverflow.com/questions/2738671/please-explain-nhibernate-hilo http://stackoverflow.com/q ...

  10. SSH basics

    SSH, Secure SHell, was designed and created to provide the best security when accessing another comp ...