查找数据库大小和表大小
数据库 查找 大小 和表
2023-09-14 08:56:50 时间
在使用云数据库时,如aws rds、阿里云rds等等,没有提供系统级别的权限,要想获知数据库和表的大小就只好通过查询语句来了。
查看MySQL数据库大小SELECT table_schema “Database Name”, sum( data_length + index_length ) / 1024 / 1024 “Database Size in MB” FROM information_schema.TABLES GROUP BY table_schema;
mysql SELECT table_schema “Database Name”, sum( data_length + index_length ) / 1024 / 1024 “Database Size in MB” FROM information_schema.TABLES GROUP BY table_schema; +——————–+———————+ | Database Name | Database Size in MB | +——————–+———————+ | dev_xian7_cn | 0.06250000 | | fuwu_ttlsa_com | 0.80861568 | | information_schema | 0.00781250 | | main | 0.12500000 | | mysql | 0.63574028 | | my_xian7_cn | 5.06250000 | | www_ttlsa_com | 81.73545456 | | www_ttmark_com | 31.87838650 | | wx | 0.00613022 | | zhifu_xian7_cn | 1.95312500 | +——————–+———————+ 10 rows in set (1.04 sec)
查看MySQL表大小
SELECT table_name AS “Tables”,round(((data_length + index_length) / 1024 / 1024), 2) “Size in MB” FROM information_schema.TABLES WHERE table_schema = “www_ttlsa_com” ORDER BY (data_length + index_length) DESC;
mysql SELECT table_name AS “Tables”,round(((data_length + index_length) / 1024 / 1024), 2) “Size in MB” - FROM information_schema.TABLES - WHERE table_schema = “www_ttlsa_com” - ORDER BY (data_length + index_length) DESC; +———————————-+————+ | Tables | Size in MB | +———————————-+————+ | ttlsa_postmeta | 29.74 | | ttlsa_posts | 25.04 | | ttlsa_redirection_404 | 15.30 | | ttlsa_sph_stats | 2.53 | | ttlsa_options | 2.53 | | ttlsa_comments | 1.44 | | ttlsa_commentmeta | 1.17 | | ttlsa_redirection_logs | 1.11 | | ttlsa_usermeta | 0.75 | | ttlsa_cst_files | 0.70 | | ttlsa_term_relationships | 0.38 | | ttlsa_redirection_items | 0.30 | | ttlsa_terms | 0.28 | | ttlsa_term_taxonomy | 0.19 | | ttlsa_post_views_realtime | 0.07 | | ttlsa_wp_rp_tags | 0.06 | | ttlsa_users | 0.04 | | ttlsa_ez_adsense_options | 0.04 | | ttlsa_post_views_history | 0.03 | | ttlsa_links | 0.01 | | ttlsa_pollsip | 0.00 | | ttlsa_redirection_groups | 0.00 | | ttlsa_redirection_modules | 0.00 | | ttlsa_termmeta | 0.00 | | ttlsa_woocommerce_order_itemmeta | 0.00 | | ttlsa_post_views_summary | 0.00 | | ttlsa_mobilepress | 0.00 | | ttlsa_pollsa | 0.00 | | ttlsa_ahm_download_stats | 0.00 | | ttlsa_pollsq | 0.00 | | ahm_files | 0.00 | | ttlsa_sph_counter | 0.00 | | ttlsa_wpo_campaign_category | 0.00 | | ttlsa_gravatars | 0.00 | | ttlsa_woocommerce_order_items | 0.00 | | ttlsa_nggv_votes | 0.00 | | ttlsa_wpo_campaign_word | 0.00 | | ttlsa_seo_title_tag_tag | 0.00 | | ttlsa_nggv_settings | 0.00 | | ttlsa_wpo_campaign_post | 0.00 | | ttlsa_wpo_campaign_feed | 0.00 | +———————————-+————+ 41 rows in set (0.00 sec)
找出前10的表大小
SELECT CONCAT(table_schema, ‘.’, table_name), CONCAT(ROUND(table_rows / 1000000, 2), ‘M’) rows, CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), ‘G’) DATA, CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), ‘G’) idx, CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), ‘G’) total_size, ROUND(index_length / data_length, 2) idxfrac FROM information_schema.TABLES ORDER BY data_length + index_length DESC LIMIT 10;
mysql SELECT CONCAT(table_schema, ‘.’, table_name), - CONCAT(ROUND(table_rows / 1000000, 2), ‘M’) rows, - CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), ‘G’) DATA, - CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), ‘G’) idx, - CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), ‘G’) total_size, - ROUND(index_length / data_length, 2) idxfrac - FROM information_schema.TABLES - ORDER BY data_length + index_length DESC - LIMIT 10; +—————————————+——-+——-+——-+————+———+ | CONCAT(table_schema, ‘.’, table_name) | rows | DATA | idx | total_size | idxfrac | +—————————————+——-+——-+——-+————+———+ | www_ttlsa_com.ttlsa_postmeta | 0.01M | 0.02G | 0.01G | 0.03G | 0.65 | | www_ttlsa_com.ttlsa_posts | 0.00M | 0.01G | 0.02G | 0.02G | 1.66 | | www_ttmark_com.tm_posts | 0.01M | 0.01G | 0.01G | 0.02G | 0.57 | | www_ttlsa_com.ttlsa_redirection_404 | 0.01M | 0.01G | 0.01G | 0.01G | 0.83 | | www_ttmark_com.tm_postmeta | 0.10M | 0.01G | 0.00G | 0.01G | 0.47 | | my_xian7_cn.tbl_pp_user | 0.01M | 0.00G | 0.00G | 0.00G | 0.00 | | www_ttlsa_com.ttlsa_sph_stats | 0.03M | 0.00G | 0.00G | 0.00G | 0.95 | | www_ttlsa_com.ttlsa_options | 0.00M | 0.00G | 0.00G | 0.00G | 0.02 | | zhifu_xian7_cn.tbl_pay_trade | 0.00M | 0.00G | 0.00G | 0.00G | 0.13 | | my_xian7_cn.t_user | 0.00M | 0.00G | 0.00G | 0.00G | 0.00 | +—————————————+——-+——-+——-+————+———+ 10 rows in set (0.20 sec)
数据库实验一:数据库与数据表定义(2)—— 数据表相关操作 使用T-SQL命令方法创建自定义数据类型myName2为Nvarchar(20),不允许为空;自定义数据类型myDept为char(50),允许为空。(提示:CREATE TYPE…FROM命令)
你还不知道什么是数据库的索引吗 在MySQL的官方文档里对于索引的定义是:索引(Index)是帮助MySQL高效获取数据的数据结构(有序)。在数据之外,数据库系统还维护着满足特定查找算法的数据结构,这些数据结构以某种方式引用(指向)数据,这样就可以在这些数据结构上实现高级查找算法,这种数据结构就是索引。
数据库、数据表的基本操作及查询数据 数据库、数据表的基本操作及查询数据数据库的基本操作创建数据库 CREATE DATABASE database_namedatabase_name为要创建的数据库的名称删除数据库 DROP DATABASE database_namedatabase_name为要删除的数据库的名称数据库存储引擎数据库存储引擎是数据库底层软件组成,数据库管理系统(DBMS)使用数据引擎进行创建、查询、更新和删除数据操作。
相关文章
- RBO和CBO的基本概念详解数据库
- oracle数据库视图,序列,索引的sql语句查看详解数据库
- 大数据量下的查找最新的几条数据的通用方法详解数据库
- 数据库实战班尚学堂 Oracle 数据库实战,由马士兵教你学!(尚学堂马士兵oracle)
- Oracle数据库对比工具:快速对比、精准查找(oracle数据对比工具)
- 用户Oracle数据库中添加新用户的操作步骤(oracle添加数据库)
- 解决Oracle数据库修改Job的方法(oracle修改job)
- Oracle数据库查找列技巧(oracle查找列)
- Oracle数据库:如何查找表的主键?(oracle查表主键)
- 如何在Oracle数据库中查找外键(oracle查找外键)
- MySQL数据库匹配,快速高效的数据查找与筛选(mysql数据库匹配)
- MySQL数据库精通:百度网盘免费课程(mysql教程百度网盘)
- MySQL快速查找数据库中记录的技巧(mysql 查找数据库)
- MSSQL数据库查找重复数据的方法(mssql 查重复数据)
- MySQL语法:深入了解你的数据库知识(mysql 的语法)
- 构建MSSQL数据库:查询包含特定字段的记录(mssql查找包含字段)
- Oracle 数据库中全表搜索特定值的实现方法(oracle 全库查找值)
- MySQL数据库操作时,遇到1205错误该怎么办(mysql中1205错误)
- 数据库如何使用C语言连接本地Oracle数据库(c 连本地oracle)
- 备份使用cmd配置MySQL数据库备份(cmd中mysql数据库)
- 精准查找C语言查询Oracle数据库中的表名(c oracle查询表名)
- C程序与Oracle数据库实现回滚操作(c oracle 回滚)
- 数据Greenplum平台下实现Oracle数据库数据读取(gp读取oracle)
- 查找Oracle数据库中的事务ID(oracle 事务id)
- Oracle 中查找表揭秘您的数据库之谜(oracle中查找有啥表)
- Oracle数据库中字符串拼接技巧(oracle中字符拼接)