oracle sql 表个数,【oracleSQL】查看当前用户各个表的记录数
【oracle】查看當前用戶各個表的記錄數
因沒有dba權限,當前用戶下查看全部表名,只能通過user_tables視圖訪問。https://www.cndba.cn/debimeng/article/3234https://www.cndba.cn/debimeng/article/3234
方法一:(直接訪問user_tables)
select t.table_name,t.num_rows from user_tables t;
https://www.cndba.cn/debimeng/article/3234https://www.cndba.cn/debimeng/article/3234
https://www.cndba.cn/debimeng/article/3234
但有一個問題,有可能查看num_rows字段沒有數據,因其統計信息不完整。https://www.cndba.cn/debimeng/article/3234
https://www.cndba.cn/debimeng/article/3234
https://www.cndba.cn/debimeng/article/3234https://www.cndba.cn/debimeng/article/3234
方法二:(存儲過程)
https://www.cndba.cn/debimeng/article/3234
create or replace procedure tj_cuser_tablenums is
--變量
v_tablename varchar2(100);
v_sql varchar2(200);
v_count int;
--獲取當前數據庫中的所有表的表名
cursor table_loop is select table_name from user_tables;
begin
--打開游標
open table_loop;
loop
fetch table_loop into v_tablename;
--如獲取不到表名或已獲取完就退出循環
exit when table_loop %notfound;
v_sql :='select count(1) from ' || v_tablename;
--執行sql語句
execute immediate v_sql into v_count;
--輸出
dbms_output.put_line(v_tablename || ':' v_count);
end loop;
close table_loop;
end tj_cuser_tablenums;
版權聲明:本文為博主原創文章,未經博主允許不得轉載。
當前用戶各個表的記錄數 user_tables
總結
以上是生活随笔為你收集整理的oracle sql 表个数,【oracleSQL】查看当前用户各个表的记录数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php兼容编码,PHP截取字符串编码(兼
- 下一篇: oracle的scn增量备份,【Orac