在oracle中,可以利用SELECT语句查询数据条数,该语句用于简单的数据查询,语法为“SELECT sum(num_rows) FROM user_tables;”。
本教程操作环境:Windows10系统、Oracle 11g版、Dell G3电脑。
系统表中统计:
SELECT sum(num_rows) FROM user_tables;
结果:
示例:
还有一种方法需要写存储过程统计
示例如下:
declare v_tName varchar(50); v_sqlanalyze varchar(500); v_num number; v_sql varchar(500); cursor c1 is select table_name from user_tables; begin open c1; loop fetch c1 into v_tName; if c1%found then v_sqlanalyze :='analyze table '||v_tName||' estimate statistics'; execute immediate v_sqlanalyze; v_sql := 'select NUM_ROWS from user_tables where table_name =upper('''||v_tName||''')'; execute immediate v_sql into v_num; dbms_output.put_line('表名: '||v_tName||' 行数: '||v_num); else exit; end if; end loop; end;
推荐教程:《Oracle视频教程》
以上就是oracle怎样查询数据条数的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号