mysql -u root -pmysql;
SELECT TABLE_NAME AS "Table Name", table_rows AS "Quant of Rows", ROUND((data_length + index_length)/1024/1024,2) AS "Total Size Mb" FROM information_schema.TABLES WHERE information_schema.TABLES.table_schema='database_name';
我想创建一个 shell 脚本来执行这些命令并返回结果。
我如何通过 shell 脚本运行该命令?
答案1
mysql -u root -pmysql << eof
SELECT TABLE_NAME AS "Table Name", table_rows AS "Quant of Rows", ROUND((data_length + index_length)/1024/1024,2) AS "Total Size Mb" FROM information_schema.TABLES WHERE information_schema.TABLES.table_schema='database_name';
eof