统计Mysql库中每个表的总行数,解决table_rows不准确问题

这篇具有很好参考价值的文章主要介绍了统计Mysql库中每个表的总行数,解决table_rows不准确问题。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1、拼接SQL

select
	substring( GROUP_CONCAT(a.sf SEPARATOR ''),1,length(GROUP_CONCAT(a.sf SEPARATOR ''))-10) as sql_str
from
	( select concat(
    'select "', 
    TABLE_name , 
    '", count(*) as row_num from ', 
    TABLE_SCHEMA, 
    '.',
    TABLE_name,
    ' union all '
) as sf
from
	information_schema.tables
where
	TABLE_SCHEMA = 'szwx') a

注意:GROUP_CONCAT()默认容量是1024,拼接sql会出现截断,设置的大一些。

执行:SET SESSION group_concat_max_len = 102400;

2.输出SQL

select "city_government_service", count(*) as row_num from szwx.city_government_service union all select "city_production_pack", count(*) as row_num from szwx.city_production_pack union all select "city_service_pack", count(*) as row_num from szwx.city_service_pack union all select "city_traffic_pack", count(*) as row_num from szwx.city_traffic_pack union all select "czj_dwd_wx_expenditure_report", count(*) as row_num from szwx.czj_dwd_wx_expenditure_report union all select "czj_dwd_wx_financeincome", count(*) as row_num from szwx.czj_dwd_wx_financeincome union all select "czj_dwd_wx_income_report", count(*) as row_num from szwx.czj_dwd_wx_income_report union all select "czj_dwd_wx_tax_revenue", count(*) as row_num from szwx.czj_dwd_wx_tax_revenue union all select "dwd_wx_geography_tab", count(*) as row_num from szwx.dwd_wx_geography_tab union all select "dwd_wx_tourist_route", count(*) as row_num from szwx.dwd_wx_tourist_route union all select "dwd_wx_tourist_spots", count(*) as row_num from szwx.dwd_wx_tourist_spots union all select "fgj_great_item_table", count(*) as row_num from szwx.fgj_great_item_table union all select "jyj_dwd_teacher_education", count(*) as row_num from szwx.jyj_dwd_teacher_education union all select "jyj_dwd_wx_expected_retire_data", count(*) as row_num from szwx.jyj_dwd_wx_expected_retire_data union all select "jyj_dwd_wx_school_counts", count(*) as row_num from szwx.jyj_dwd_wx_school_counts union all select "jyj_dwd_wx_student_data", count(*) as row_num from szwx.jyj_dwd_wx_student_data union all select "jyj_dwd_wx_teacher_data", count(*) as row_num from szwx.jyj_dwd_wx_teacher_data union all select "lyj_dwd_wx_forestry", count(*) as row_num from szwx.lyj_dwd_wx_forestry union all select "lyj_june2023_scenicareareception", count(*) as row_num from szwx.lyj_june2023_scenicareareception union all select "mzj_cx_ep_support_statistics", count(*) as row_num from szwx.mzj_cx_ep_support_statistics union all select "mzj_dis_disabled_statistics", count(*) as row_num from szwx.mzj_dis_disabled_statistics union all select "mzj_dwd_wx_county_civil_affairs_objects_and_standard", count(*) as row_num from szwx.mzj_dwd_wx_county_civil_affairs_objects_and_standard union all select "mzj_dwd_wx_county_orphan_statistic", count(*) as row_num from szwx.mzj_dwd_wx_county_orphan_statistic union all select "mzj_dwd_wx_county_social_welfare", count(*) as row_num from szwx.mzj_dwd_wx_county_social_welfare union all select "mzj_dwd_wx_minimum_living_security_objects", count(*) as row_num from szwx.mzj_dwd_wx_minimum_living_security_objects union all select "nyncj_dwd_wx_cold_storage_subsidy_info", count(*) as row_num from szwx.nyncj_dwd_wx_cold_storage_subsidy_info union all select "py_cloud_img", count(*) as row_num from szwx.py_cloud_img union all select "qyrkxxgl_contraception_statistics", count(*) as row_num from szwx.qyrkxxgl_contraception_statistics union all select "qyrkxxgl_fecund_women_conditions", count(*) as row_num from szwx.qyrkxxgl_fecund_women_conditions union all select "qyrkxxgl_population_basic_info", count(*) as row_num from szwx.qyrkxxgl_population_basic_info union all select "qyrkxxgl_population_natural_change", count(*) as row_num from szwx.qyrkxxgl_population_natural_change union all select "scjdglj_basic_library_establishment_query", count(*) as row_num from szwx.scjdglj_basic_library_establishment_query union all select "scjdglj_task_progress_query", count(*) as row_num from szwx.scjdglj_task_progress_query union all select "shp_dwd_wx_jg", count(*) as row_num from szwx.shp_dwd_wx_jg union all select "tjj_domestic_trade", count(*) as row_num from szwx.tjj_domestic_trade union all select "tjj_dwd_wx_2023_grain_production", count(*) as row_num from szwx.tjj_dwd_wx_2023_grain_production union all select "tjj_dwd_wx_agri_forest_total_output", count(*) as row_num from szwx.tjj_dwd_wx_agri_forest_total_output union all select "tjj_dwd_wx_animal_veggie_prod", count(*) as row_num from szwx.tjj_dwd_wx_animal_veggie_prod union all select "tjj_dwd_wx_industrial_value_added_growth", count(*) as row_num from szwx.tjj_dwd_wx_industrial_value_added_growth union all select "tjj_dwd_wx_major_target_performance", count(*) as row_num from szwx.tjj_dwd_wx_major_target_performance union all select "tjj_dwd_wx_monthly_economic_indicators_monitor", count(*) as row_num from szwx.tjj_dwd_wx_monthly_economic_indicators_monitor union all select "tjj_dwd_wx_national_economic_accounting", count(*) as row_num from szwx.tjj_dwd_wx_national_economic_accounting union all select "tjj_fixed_asset_investment", count(*) as row_num from szwx.tjj_fixed_asset_investment union all select "tjj_industrial_economic_benefit", count(*) as row_num from szwx.tjj_industrial_economic_benefit union all select "tjj_industrial_output", count(*) as row_num from szwx.tjj_industrial_output union all select "tjj_industrial_sales", count(*) as row_num from szwx.tjj_industrial_sales union all select "tjj_real_estate_dev_status", count(*) as row_num from szwx.tjj_real_estate_dev_status union all select "wtj_dwd_wx_health_service_statistics", count(*) as row_num from szwx.wtj_dwd_wx_health_service_statistics union all select "wtj_public_health_data_65yearold_management_statistics", count(*) as row_num from szwx.wtj_public_health_data_65yearold_management_statistics union all select "wtj_public_health_data_diabetes_health_service_statistics", count(*) as row_num from szwx.wtj_public_health_data_diabetes_health_service_statistics union all select "wtj_public_health_data_health_education_service_statistics", count(*) as row_num from szwx.wtj_public_health_data_health_education_service_statistics union all select "wtj_public_health_data_hyperglycemia_health_service_statistics", count(*) as row_num from szwx.wtj_public_health_data_hyperglycemia_health_service_statistics union all select "wtj_public_health_data_hypertension_service_statistics", count(*) as row_num from szwx.wtj_public_health_data_hypertension_service_statistics union all select "wtj_public_health_data_mental_disorder_health_service_statistics", count(*) as row_num from szwx.wtj_public_health_data_mental_disorder_health_service_statistics union all select "wtj_public_health_data_standard_profile_statistics", count(*) as row_num from szwx.wtj_public_health_data_standard_profile_statistics union all select "wtj_public_health_data_tcm_health_service_statistics", count(*) as row_num from szwx.wtj_public_health_data_tcm_health_service_statistics union all select "xczx_dwd_wx_project_stats", count(*) as row_num from szwx.xczx_dwd_wx_project_stats union all select "xczx_hamlet_type_statistics", count(*) as row_num from szwx.xczx_hamlet_type_statistics union all select "xczx_poverty_mem_statistics", count(*) as row_num from szwx.xczx_poverty_mem_statistics union all select "xczx_project_cc_statistics", count(*) as row_num from szwx.xczx_project_cc_statistics union all select "xczx_village_db_statistics", count(*) as row_num from szwx.xczx_village_db_statistics union all select "xczx_village_work_statistics", count(*) as row_num from szwx.xczx_village_work_statistics union all select "ybj_dwd_wx_medical_insurance_data", count(*) as row_num from szwx.ybj_dwd_wx_medical_insurance_data union all select "yjj_dwd_wx_shelter", count(*) as row_num from szwx.yjj_dwd_wx_shelter 

执行输出

 

统计Mysql库中每个表的总行数,解决table_rows不准确问题,mysql,数据库文章来源地址https://www.toymoban.com/news/detail-666592.html

到了这里,关于统计Mysql库中每个表的总行数,解决table_rows不准确问题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 统计后端项目代码的总行数

    统计后端项目代码的总行数,可以有三种方式:Git Bash 命令行页面中使用命令统计、使用 VS Code中的插件统计 或者 IntelliJ IDEA 中的插件统计。 方式一、使用命令 1、选择项目路径,进入Git Bash页面 在后端项目目录下,右键选择“Git Bash Here”,进入 Git Bash 的命令行页面。 2、执

    2024年02月14日
    浏览(35)
  • git怎么样快速统计自己的代码总行数

    今天领导突然找我,说要统计自己入职以来,在gitlab上的代码总行数和 commit 量! 于是,我就有了以下总结。 注意: 一定要在 git bash 终端打开。不要在 vscode 终端、powershell 等终端执行命令(否则,可能会报错) 要在当前项目的根目录下执行 1. 怎么样统计 commit 总数量? 要

    2024年01月20日
    浏览(36)
  • 项目代码行数统计,总行数统计,任意语言,忽略目录/指定多个文件,分分钟搞定。

    工具大小:3.6M 下载地址: https://www.zeropo.com/SourceCounter.zip 使用方式:下载运行exe(无需安装) 其他拓展 如质量指标:单元测试用例密度,单元测试缺陷密度,综合测试用例密度,综合测试缺陷密度 人工数和成本分析设定:代码生产率,多少行/人每月、一个人月的上班日数

    2024年02月19日
    浏览(44)
  • python统计每个单词出现的次数

    编程要求 请按照函数的注释,补充程序中缺失部分语句,按要求实现如下程序功能:‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬ word_frequency() 函数统计并以字典类型返回每个

    2024年02月11日
    浏览(45)
  • python3 统计redis中每个DB占用的内存大小

            在一些业务中,会使用多个DB来缓存不同类型的业务数据,有时候redis占用内存过高,造成服务异常。         redis可以通过dbsize命令来查看当前选择的DB的key的数量,有时候仅仅看key的数量可能还不能直观反映哪块业务数据占用内存多,redis也没有直接的命令可以

    2024年01月16日
    浏览(40)
  • 【MySQL】更改表的主键报错及解决办法

    报错: [HY000][3750] Unable to create or change a table without a primary key, when the system variable ‘sql_require_primary_key’ is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing

    2024年01月20日
    浏览(54)
  • 2023-06-13:统计高并发网站每个网页每天的 UV 数据,结合Redis你会如何实现?

    2023-06-13:统计高并发网站每个网页每天的 UV 数据,结合Redis你会如何实现? 答案2023-06-13: 如果统计 PV (页面浏览量)那非常好办,可以考虑为每个网页创建一个独立的 Redis 计数器,并将日期添加为键(key)的后缀。当网页收到请求时,对应的计数器将被递增。对于每天的

    2024年02月08日
    浏览(87)
  • 编写 Scala 工程代码,将 MySQL 库中的表增量抽取到 Hive库中对应表中

    提示:本文采用IDEA编写代码 搭建好spark,推荐一篇较好的文章:spark3.3.0安装部署过程。 注:如果需要运行 yarn 模式,在 spark-env.sh 文件末尾添加: export YARN_CONF_DIR=/opt/hadoop-3.1.3/etc/hadoop export HADOOP_CONF_DIR=/opt/hadoop-3.1.3/etc/hadoop 搭建完spark 集群 后,在spark的 jars 目录下放入mys

    2023年04月14日
    浏览(65)
  • 【云计算与大数据计算】Hadoop MapReduce实战之统计每个单词出现次数、单词平均长度、Grep(附源码 )

    需要全部代码请点赞关注收藏后评论区留言私信~~~ 下面通过WordCount,WordMean等几个例子讲解MapReduce的实际应用,编程环境都是以Hadoop MapReduce为基础 WordCount用于计算文件中每个单词出现的次数,非常适合采用MapReduce进行处理,处理单词计数问题的思路很简单,在 Map阶段处理每

    2024年02月16日
    浏览(47)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包