> 데이터 베이스 > MySQL 튜토리얼 > Oracle 查找数据库中有记录的表

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
풀어 주다: 2016-06-07 16:59:04
원래의
1010명이 탐색했습니다.

通过执行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 is cursor cur_tab is select table_name from user_tables; record_cur_tab cur_tab%rowtype; begin delete from DataTables; open cur_tab; loop fetch 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;

linux

관련 라벨:
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿