您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Oracle 查找数据库中有记录的表

2024/6/9 7:15:11发布29次查看
通过执行select num_rows,table_name from user_tables where num_rowsgt;0,是可以达到效果的。但是:有时候数据是不准的,原因
通过执行select num_rows,table_name from user_tables where num_rows>0,是可以达到效果的。
但是:有时候数据是不准的,原因是执行该查询的时候要先对表进行分析。
分析表的语法为:analyze table table_name compute statistics;
如何批量对表进行分析呢?
1、存储过程+游标,循环,ok没有问题,但是有点麻烦。
create or replace procedure pro_analyzetables iscursor cur_tab isselect table_name from user_tables;record_cur_tab cur_tab%rowtype;begindelete from datatables;open cur_tab;loopfetch cur_tab into record_cur_tab;exit when cur_tab%notfound;execute immediate 'analyze table '||record_cur_tab.table_name||' compute statistics';end loop;insert into datatables (select table_name,num_rows from user_tables where num_rows>0);end pro_analyzetables;

该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product