|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
DB_USER="postgres"
DB_PASSWORD="Csjd%951"
DB_HOST="192.168.101.1"
DB_NAME="commonframex"
date=(date +'%Y-%m-%d') SQL_QUERY="WITH count_table AS (SELECT 'datacollection.cm_lte_base' AS tables_name, COUNT ( * ) AS COUNT FROM datacollection.cm_lte_base UNION ALL SELECT 'datacollection.cm_lte_sonpolicyeslte_zte', COUNT ( * ) FROM datacollection.cm_lte_sonpolicyeslte_zte UNION ALL SELECT 'datacollection.cm_nr_gnodeb_hw', COUNT ( * ) FROM datacollection.cm_nr_gnodeb_hw UNION ALL SELECT 'datacollection.cm_lte_soncellpolicyfddlte_zte', COUNT ( * ) FROM datacollection.cm_lte_soncellpolicyfddlte_zte UNION ALL SELECT 'datacollection.cm_lte_enbfunction_v2_hw', COUNT ( * ) FROM datacollection.cm_lte_enbfunction_v2_hw UNION ALL SELECT 'datacollection.cm_nr_managedelement_hw', COUNT ( * ) FROM datacollection.cm_nr_managedelement_hw UNION ALL SELECT 'datacollection.cm_lte_soncellpolicy_zte', COUNT ( * ) FROM datacollection.cm_lte_soncellpolicy_zte UNION ALL SELECT 'datacollection.cm_nr_inventoryunitrru_hw', COUNT ( * ) FROM datacollection.cm_nr_inventoryunitrru_hw UNION ALL SELECT 'datacollection.cm_nr_carrierespolicy_zte', COUNT ( * ) FROM datacollection.cm_nr_carrierespolicy_zte UNION ALL SELECT 'datacollection.cm_nr_channelespolicy_zte', COUNT ( * ) FROM datacollection.cm_nr_channelespolicy_zte UNION ALL SELECT 'datacollection.cm_nr_dtxespolicy_zte', COUNT ( * ) FROM datacollection.cm_nr_dtxespolicy_zte UNION ALL SELECT 'datacollection.cm_nr_gnodeb_zte', COUNT ( * ) FROM datacollection.cm_nr_gnodeb_zte UNION ALL SELECT 'datacollection.cm_nr_base', COUNT ( * ) FROM datacollection.cm_nr_base UNION ALL SELECT 'datacollection.cm_lte_sonpolicyestdd_zte', COUNT ( * ) FROM datacollection.cm_lte_sonpolicyestdd_zte UNION ALL SELECT 'datacollection.cm_nr_nrcell_hw', COUNT ( * ) FROM datacollection.cm_nr_nrcell_hw UNION ALL SELECT 'datacollection.cm_lte_enbfunction_zte', COUNT ( * ) FROM datacollection.cm_lte_enbfunction_zte UNION ALL SELECT 'datacollection.cm_lte_enbfunction_v2_zte', COUNT ( * ) FROM datacollection.cm_lte_enbfunction_v2_zte UNION ALL SELECT 'datacollection.cm_lte_soncellpolicytdd_zte', COUNT ( * ) FROM datacollection.cm_lte_soncellpolicytdd_zte UNION ALL SELECT 'datacollection.cm_nr_nrcell_zte', COUNT ( * ) FROM datacollection.cm_nr_nrcell_zte UNION ALL SELECT 'datacollection.cm_nr_gnodeb_nok', COUNT ( * ) FROM datacollection.cm_nr_gnodeb_nok UNION ALL SELECT 'datacollection.cm_nr_nrcell_nok', COUNT ( * ) AS COUNT FROM datacollection.cm_nr_nrcell_nok UNION ALL SELECT 'datacollection.cm_lte_eutrancelltdd_hw', COUNT ( * ) FROM datacollection.cm_lte_eutrancelltdd_hw UNION ALL SELECT 'datacollection.cm_lte_soncellpolicytddlte_zte', COUNT ( * ) FROM datacollection.cm_lte_soncellpolicytddlte_zte UNION ALL SELECT 'datacollection.cm_nr_nrcelldu_zte', COUNT ( * ) FROM datacollection.cm_nr_nrcelldu_zte UNION ALL SELECT 'datacollection.cm_nr_nrpgrp_nok', COUNT ( * ) FROM datacollection.cm_nr_nrpgrp_nok UNION ALL SELECT 'datacollection.cm_lte_sonpolicyes_zte', COUNT ( * ) FROM datacollection.cm_lte_sonpolicyes_zte UNION ALL SELECT 'datacollection.cm_lte_eutrancelltdd_v1_dt', COUNT ( * ) FROM datacollection.cm_lte_eutrancelltdd_v1_dt UNION ALL SELECT 'datacollection.cm_lte_inventoryunitrru_dt', COUNT ( * ) FROM datacollection.cm_lte_inventoryunitrru_dt UNION ALL SELECT 'datacollection.cm_lte_enbfunction_eric', COUNT ( * ) FROM datacollection.cm_lte_enbfunction_eric UNION ALL SELECT 'datacollection.cm_lte_eutrancelltdd_eric', COUNT ( * ) FROM datacollection.cm_lte_eutrancelltdd_eric UNION ALL SELECT 'datacollection.cm_nr_gnodeb_eric', COUNT ( * ) FROM datacollection.cm_nr_gnodeb_eric UNION ALL SELECT 'datacollection.cm_nr_nrcell_eric', COUNT ( * ) FROM datacollection.cm_nr_nrcell_eric UNION ALL SELECT 'datacollection.cm_lte_eutrancellfdd_v1_zte', COUNT ( * ) FROM datacollection.cm_lte_eutrancellfdd_v1_zte UNION ALL SELECT 'datacollection.cm_lte_eutrancelltdd_v1_zte', COUNT ( * ) FROM datacollection.cm_lte_eutrancelltdd_v1_zte UNION ALL SELECT 'datacollection.cm_lte_eutranrelation_zte', COUNT ( * ) FROM datacollection.cm_lte_eutranrelation_zte UNION ALL SELECT 'datacollection.cm_nr_eutrancellrelation_zte', COUNT ( * ) FROM datacollection.cm_nr_eutrancellrelation_zte UNION ALL SELECT 'datacollection.cm_nr_nrcellrelation_zte', COUNT ( * ) FROM datacollection.cm_nr_nrcellrelation_zte UNION ALL SELECT 'datacollection.cm_lte_enbfuncation_dt', COUNT ( * ) FROM datacollection.cm_lte_enbfuncation_dt UNION ALL SELECT 'datacollection.cm_lte_eutrancelltdd_dt', COUNT ( * ) FROM datacollection.cm_lte_eutrancelltdd_dt UNION ALL SELECT 'datacollection.cm_nr_gnodeb_dt', COUNT ( * ) AS COUNT FROM datacollection.cm_nr_gnodeb_dt UNION ALL SELECT 'datacollection.cm_lte_inventoryunitshelf_eric', COUNT ( * ) FROM datacollection.cm_lte_inventoryunitshelf_eric UNION ALL SELECT 'datacollection.cm_lte_eutrancelltdd_zte', COUNT ( * ) FROM datacollection.cm_lte_eutrancelltdd_zte UNION ALL SELECT 'datacollection.cm_nr_nrcell_dt', COUNT ( * ) FROM datacollection.cm_nr_nrcell_dt UNION ALL SELECT 'datacollection.cm_nr_nrcellduphysical_dt', COUNT ( * ) FROM datacollection.cm_nr_nrcellduphysical_dt UNION ALL SELECT 'datacollection.cm_nr_nrrruenergyconserve_dt', COUNT ( * ) FROM datacollection.cm_nr_nrrruenergyconserve_dt UNION ALL SELECT 'datacollection.cm_lte_enbfunction_nok', COUNT ( * ) FROM datacollection.cm_lte_enbfunction_nok UNION ALL SELECT 'datacollection.cm_lte_eutrancelltdd_nok', COUNT ( * ) FROM datacollection.cm_lte_eutrancelltdd_nok UNION ALL SELECT 'datacollection.cm_lte_psgrp_nok', COUNT ( * ) FROM datacollection.cm_lte_psgrp_nok UNION ALL SELECT 'energysavingrules.lte_zx_eutrancelltdd_v2', COUNT ( * ) FROM energysavingrules.lte_zx_eutrancelltdd_v2 UNION ALL SELECT 'energysavingrules.eutrancelltdd_nrm', COUNT ( * ) FROM energysavingrules.eutrancelltdd_nrm UNION ALL SELECT 'energysavingrules.lte_zx_enbfunction', COUNT ( * ) FROM energysavingrules.lte_zx_enbfunction UNION ALL SELECT 'energysavingrules.eutrancellfdd_nrm', COUNT ( * ) FROM energysavingrules.eutrancellfdd_nrm UNION ALL SELECT 'energysavingrules.nr_zx_nrcell', COUNT ( * ) FROM energysavingrules.nr_zx_nrcell UNION ALL SELECT 'energysavingrules.sa_hua_managedelement', COUNT ( * ) FROM energysavingrules.sa_hua_managedelement UNION ALL SELECT 'energysavingrules.sa_zx_carrierespolicy', COUNT ( * ) FROM energysavingrules.sa_zx_carrierespolicy UNION ALL SELECT 'energysavingrules.sa_hua_nrducellalgoswitch', COUNT ( * ) FROM energysavingrules.sa_hua_nrducellalgoswitch UNION ALL SELECT 'energysavingrules.lte_hua_eutrancelltdd_v2', COUNT ( * ) FROM energysavingrules.lte_hua_eutrancelltdd_v2 UNION ALL SELECT 'energysavingrules.lte_zx_inventoryunitrru', COUNT ( * ) FROM energysavingrules.lte_zx_inventoryunitrru UNION ALL SELECT 'energysavingrules.sa_hua_nrducellpowersaving', COUNT ( * ) FROM energysavingrules.sa_hua_nrducellpowersaving UNION ALL SELECT 'energysavingrules.sa_zx_managedelement', COUNT ( * ) AS COUNT FROM energysavingrules.sa_zx_managedelement UNION ALL SELECT 'energysavingrules.lte_hua_enbfunction', COUNT ( * ) FROM energysavingrules.lte_hua_enbfunction UNION ALL SELECT 'energysavingrules.lte_hua_enodebalgoswitch', COUNT ( * ) FROM energysavingrules.lte_hua_enodebalgoswitch UNION ALL SELECT 'energysavingrules.sa_hua_gnbdufunction', COUNT ( * ) FROM energysavingrules.sa_hua_gnbdufunction UNION ALL SELECT 'energysavingrules.sa_hua_nrcellduphysical', COUNT ( * ) FROM energysavingrules.sa_hua_nrcellduphysical UNION ALL SELECT 'energysavingrules.sa_hua_nrducelltrp', COUNT ( * ) FROM energysavingrules.sa_hua_nrducelltrp UNION ALL SELECT 'energysavingrules.sa_zx_antconfig', COUNT ( * ) FROM energysavingrules.sa_zx_antconfig UNION ALL SELECT 'energysavingrules.sa_zx_channelespolicy', COUNT ( * ) FROM energysavingrules.sa_zx_channelespolicy UNION ALL SELECT 'energysavingrules.sa_zx_dtxespolicy', COUNT ( * ) FROM energysavingrules.sa_zx_dtxespolicy UNION ALL SELECT 'energysavingrules.sa_zx_gnbdufunction', COUNT ( * ) FROM energysavingrules.sa_zx_gnbdufunction UNION ALL SELECT 'energysavingrules.sa_zx_nrcellduphysical', COUNT ( * ) FROM energysavingrules.sa_zx_nrcellduphysical UNION ALL SELECT 'energysavingrules.lte_hua_cellrfshutdown', COUNT ( * ) FROM energysavingrules.lte_hua_cellrfshutdown UNION ALL SELECT 'energysavingrules.lte_hua_cellshutdown', COUNT ( * ) FROM energysavingrules.lte_hua_cellshutdown UNION ALL SELECT 'energysavingrules.lte_hua_managedelement', COUNT ( * ) FROM energysavingrules.lte_hua_managedelement UNION ALL SELECT 'energysavingrules.lte_zx_managedelement', COUNT ( * ) FROM energysavingrules.lte_zx_managedelement UNION ALL SELECT 'energysavingrules.nr_hua_nrcell', COUNT ( * ) FROM energysavingrules.nr_hua_nrcell UNION ALL SELECT 'energysavingrules.sa_zx_powercontroldl', COUNT ( * ) FROM energysavingrules.sa_zx_powercontroldl UNION ALL SELECT 'energysavingrules.lte_hua_inventoryunitrru', COUNT ( * ) FROM energysavingrules.lte_hua_inventoryunitrru UNION ALL SELECT 'energysavingrules.sa_zx_inventoryunitrru_jd', COUNT ( * ) FROM energysavingrules.sa_zx_inventoryunitrru_jd UNION ALL SELECT 'energysavingrules.cm_nr_base', COUNT ( * ) FROM energysavingrules.cm_nr_base UNION ALL SELECT 'energysavingrules.cm_lte_base', COUNT ( * ) AS COUNT FROM energysavingrules.cm_lte_base UNION ALL SELECT 'energysavingrules.sa_hua_inventoryunitrru_jd', COUNT ( * ) FROM energysavingrules.sa_hua_inventoryunitrru_jd UNION ALL SELECT 'energysavingrules.lte_eric_cellsleepfunction', COUNT ( * ) FROM energysavingrules.lte_eric_cellsleepfunction UNION ALL SELECT 'energysavingrules.sa_eric_gnbdufunction', COUNT ( * ) FROM energysavingrules.sa_eric_gnbdufunction UNION ALL SELECT 'energysavingrules.lte_dt_enbfunction', COUNT ( * ) FROM energysavingrules.lte_dt_enbfunction UNION ALL SELECT 'energysavingrules.lte_dt_eutrancelltdd', COUNT ( * ) FROM energysavingrules.lte_dt_eutrancelltdd UNION ALL SELECT 'energysavingrules.lte_dt_eutrancelltdd_v2', COUNT ( * ) FROM energysavingrules.lte_dt_eutrancelltdd_v2 UNION ALL SELECT 'energysavingrules.lte_dt_inventoryunitrru', COUNT ( * ) FROM energysavingrules.lte_dt_inventoryunitrru UNION ALL SELECT 'energysavingrules.lte_dt_managedelement', COUNT ( * ) FROM energysavingrules.lte_dt_managedelement UNION ALL SELECT 'energysavingrules.sa_dt_gnbdufunction', COUNT ( * ) FROM energysavingrules.sa_dt_gnbdufunction UNION ALL SELECT 'energysavingrules.sa_dt_inventoryunitrru', COUNT ( * ) FROM energysavingrules.sa_dt_inventoryunitrru UNION ALL SELECT 'energysavingrules.lte_nok_enbfunction', COUNT ( * ) FROM energysavingrules.lte_nok_enbfunction UNION ALL SELECT 'energysavingrules.lte_nok_eutrancellfdd', COUNT ( * ) FROM energysavingrules.lte_nok_eutrancellfdd UNION ALL SELECT 'energysavingrules.lte_eric_managedelement_nrm', COUNT ( * ) FROM energysavingrules.lte_eric_managedelement_nrm UNION ALL SELECT 'energysavingrules.lte_eric_enbfunction', COUNT ( * ) FROM energysavingrules.lte_eric_enbfunction UNION ALL SELECT 'energysavingrules.lte_eric_eutrancellfdd', COUNT ( * ) FROM energysavingrules.lte_eric_eutrancellfdd UNION ALL SELECT 'energysavingrules.lte_eric_eutrancelltdd', COUNT ( * ) FROM energysavingrules.lte_eric_eutrancelltdd UNION ALL SELECT 'energysavingrules.lte_eric_eutrancelltdd_v2', COUNT ( * ) FROM energysavingrules.lte_eric_eutrancelltdd_v2 UNION ALL SELECT 'energysavingrules.lte_eric_featurestate', COUNT ( * ) FROM energysavingrules.lte_eric_featurestate UNION ALL SELECT 'energysavingrules.lte_eric_mimosleepfunction', COUNT ( * ) FROM energysavingrules.lte_eric_mimosleepfunction UNION ALL SELECT 'energysavingrules.lte_eric_optionalfeaturelicens', COUNT ( * ) AS COUNT FROM energysavingrules.lte_eric_optionalfeaturelicens UNION ALL SELECT 'energysavingrules.sa_eric_inventoryunitrru', COUNT ( * ) FROM energysavingrules.sa_eric_inventoryunitrru UNION ALL SELECT 'energysavingrules.sa_eric_managedelement_nrm', COUNT ( * ) FROM energysavingrules.sa_eric_managedelement_nrm UNION ALL SELECT 'energysavingrules.sa_eric_nrcelldu', COUNT ( * ) FROM energysavingrules.sa_eric_nrcelldu UNION ALL SELECT 'energysavingrules.lte_eric_inventoryunitrru', COUNT ( * ) FROM energysavingrules.lte_eric_inventoryunitrru UNION ALL SELECT 'energysavingrules.sa_eric_nrcellduphysical', COUNT ( * ) FROM energysavingrules.sa_eric_nrcellduphysical UNION ALL SELECT 'energysavingrules.sa_dt_managedelement', COUNT ( * ) FROM energysavingrules.sa_dt_managedelement UNION ALL SELECT 'energysavingrules.sa_dt_nrcelldu', COUNT ( * ) FROM energysavingrules.sa_dt_nrcelldu UNION ALL SELECT 'energysavingrules.sa_dt_nrcellduphysical', COUNT ( * ) FROM energysavingrules.sa_dt_nrcellduphysical UNION ALL SELECT 'energysavingrules.sa_dt_nrrruenergyconserve', COUNT ( * ) FROM energysavingrules.sa_dt_nrrruenergyconserve UNION ALL SELECT 'energysavingrules.lte_nok_eutrancelltdd', COUNT ( * ) FROM energysavingrules.lte_nok_eutrancelltdd UNION ALL SELECT 'energysavingrules.lte_nok_eutrancelltdd_v2', COUNT ( * ) FROM energysavingrules.lte_nok_eutrancelltdd_v2 UNION ALL SELECT 'energysavingrules.lte_nok_inventoryunitrru', COUNT ( * ) FROM energysavingrules.lte_nok_inventoryunitrru UNION ALL SELECT 'energysavingrules.lte_nok_managedelement', COUNT ( * ) FROM energysavingrules.lte_nok_managedelement UNION ALL SELECT 'energysavingrules.sa_nok_gnbcucpfunction', COUNT ( * ) FROM energysavingrules.sa_nok_gnbcucpfunction UNION ALL SELECT 'energysavingrules.sa_nok_gnbdufunction', COUNT ( * ) FROM energysavingrules.sa_nok_gnbdufunction UNION ALL SELECT 'energysavingrules.sa_nok_inventoryunitrru', COUNT ( * ) FROM energysavingrules.sa_nok_inventoryunitrru UNION ALL SELECT 'energysavingrules.sa_nok_managedelement', COUNT ( * ) FROM energysavingrules.sa_nok_managedelement UNION ALL SELECT 'energysavingrules.sa_nok_nrcelldu', COUNT ( * ) FROM energysavingrules.sa_nok_nrcelldu UNION ALL SELECT 'energysavingrules.lte_nok_psgrp', COUNT ( * ) FROM energysavingrules.lte_nok_psgrp UNION ALL SELECT 'energysavingrules.sa_nok_nrpgrp', COUNT ( * ) AS COUNT FROM energysavingrules.sa_nok_nrpgrp UNION ALL SELECT 'energysavingrules.lte_zx_sonpolicyes', COUNT ( * ) FROM energysavingrules.lte_zx_sonpolicyes UNION ALL SELECT 'energysavingrules.lte_zx_sonpolicyeslte', COUNT ( * ) FROM energysavingrules.lte_zx_sonpolicyeslte UNION ALL SELECT 'energysavingrules.lte_zx_sonpolicyestdd', COUNT ( * ) FROM energysavingrules.lte_zx_sonpolicyestdd UNION ALL SELECT 'energysavingrules.lte_zx_soncellpolicy', COUNT ( * ) FROM energysavingrules.lte_zx_soncellpolicy UNION ALL SELECT 'energysavingrules.lte_zx_soncellpolicyfddlte', COUNT ( * ) FROM energysavingrules.lte_zx_soncellpolicyfddlte UNION ALL SELECT 'energysavingrules.lte_zx_soncellpolicytdd', COUNT ( * ) FROM energysavingrules.lte_zx_soncellpolicytdd UNION ALL SELECT 'energysavingrules.lte_zx_soncellpolicytddlte', COUNT ( * ) FROM energysavingrules.lte_zx_soncellpolicytddlte ), total_count AS ( SELECT SUM ( COUNT ) AS total FROM count_table ) SELECT * FROM count_table UNION ALL SELECT '总数', total FROM total_count;" # export PGPASSWORD=DB_PASSWORD
explain_sql=`/usr/pgsql-14/bin/psql -U DBUSER−p22345−hDB_HOST -d DBNAME−c"SQL_QUERY"`
echo "表名及统计数量
$explain_sql"
unset PGPASSWORD
将当前sql脚本导出成csv文件 |
|