MySQL 查看基本信息、库和表大小,最后修改时间

  1. 查看数据库表基本信息。
    select * from information_schema.TABLES where information_schema.TABLES.TABLE_SCHEMA = '数据库名' and information_schema.TABLES.TABLE_NAME = '表名';

  2. 查看所有mysql数据库大小
    select TABLE_SCHEMA, concat(truncate(sum(data_length)/1024/1024,2),' MB') as data_size,
    concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size
    from information_schema.tables
    group by TABLE_SCHEMA
    order by data_length desc;

  3. 查看某个库每个表的大小
    select TABLE_NAME, concat(truncate(data_length/1024/1024,2),' MB') as data_size,
    concat(truncate(index_length/1024/1024,2),' MB') as index_size
    from information_schema.tables where TABLE_SCHEMA = '库名'
    group by TABLE_NAME
    order by data_length desc;

  4. 查看库最后修改时间
    select TABLE_NAME,UPDATE_TIME from information_schema.TABLES where TABLE_SCHEMA='数据库名' order by UPDATE_TIME desc limit 1;

  5. 查看表最后修改时间
    select TABLE_NAME,UPDATE_TIME from information_schema.TABLES where TABLE_SCHEMA='数据库名' and information_schema.TABLES.TABLE_NAME = '表名';

本作品采用《CC 协议》,转载必须注明作者和本文链接
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!