找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 73|回复: 0

mysql 查询

[复制链接]

86

主题

84

回帖

728

积分

管理员

积分
728
发表于 2023-8-11 15:08:35 | 显示全部楼层 |阅读模式
查询表结构表字段
  1. SELECT
  2.         T.TABLE_NAME,
  3.         T.TABLE_COMMENT,
  4.         C.COLUMN_NAME,
  5.         C.COLUMN_COMMENT
  6. FROM
  7.         INFORMATION_SCHEMA.TABLES AS T
  8.         INNER JOIN INFORMATION_SCHEMA.COLUMNS AS C ON T.TABLE_NAME = C.TABLE_NAME
  9.         AND T.TABLE_SCHEMA = C.TABLE_SCHEMA
  10. WHERE
  11.         T.TABLE_SCHEMA = 'myerpoa';
复制代码
查看所有数据库容量大小
  1. select
  2.     table_schema as '数据库',
  3.     sum(table_rows) as '记录数',
  4.     sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',
  5.     sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'
  6.     from information_schema.tables
  7.     group by table_schema
  8.     order by sum(data_length) desc, sum(index_length) desc;
复制代码

查看所有数据库各表容量大小
  1. select
  2. table_schema as '数据库',
  3. table_name as '表名',
  4. table_rows as '记录数',
  5. truncate(data_length/1024/1024, 2) as '数据容量(MB)',
  6. truncate(index_length/1024/1024, 2) as '索引容量(MB)'
  7. from information_schema.tables
  8. order by data_length desc, index_length desc;
复制代码
查看指定数据库容量大小
  1. select
  2. table_schema as '数据库',
  3. sum(table_rows) as '记录数',
  4. sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',
  5. sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'
  6. from information_schema.tables
  7. where table_schema='mysql';
复制代码
查看指定数据库各表容量大小
  1. #例:查看mysql库各表容量大小

  2. select
  3. table_schema as '数据库',
  4. table_name as '表名',
  5. table_rows as '记录数',
  6. truncate(data_length/1024/1024, 2) as '数据容量(MB)',
  7. truncate(index_length/1024/1024, 2) as '索引容量(MB)'
  8. from information_schema.tables
  9. where table_schema='mysql'
  10. order by data_length desc, index_length desc;
复制代码


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Discuz! X

GMT+8, 2025-12-6 12:38 , Processed in 0.081886 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表