一. mysql 获取各表行数
1.1 不准确的,不推荐使用
select
table_name,
table_rows
from information_schema.tables
where table_schema = 'test'
group by table_name
order by table_rows desc;
但是这个并不能正确返回表的行数
1.2 准确的
select count(1) from {table};
问题来了: 怎么获取所有表的行数?
思路:
1. 在python里遍历所有的表。将表名作为参数传给这个SQL语句, 但在效率实在太低了。
2. 在sql语句里写,先查找出所有的表名,再将表名传给这个语句,需要设置个循环体,
@count=0
select @table=TABLE from information_schema.tables
select count(1) from @table into @count
# 这是个TODO
二. oracle 相关应用
2.1 获取各字段的长度
select
col,
DBMS_LOB.GETLENGTH(col) as len
from table