Oracle数据库中有关记录个数的查询

一、查询表中全部的记录个数

可用两种方法,一种是在oracle的系统表中统计,另一种需要写存储过程统计,方法分别如下。

1、系统表中统计:

SELECT sum(num_rows) FROM user_tables;

结果:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAATgAAACiCAIAAABal0asAAAI70lEQVR4nO2dPZKjPBBAOTpHmXxroz3AOOQSjr5kQhUX8BfIg2X9NA3IRm29V9QUK0MjN3pIAlw73ACgeYazKwAA6yAqgAEQFcAAiApgAEQFMACiAhjgLuqfv/9YWFiUy5mivv/YAKDkA0UdhvHsKuRptmJ2GYZhGLqYvn2aqI3L0Hj1XkSq0/BL9cifSl7UYRyXJfpnVJLdZSlfjVP/+7Rtglw9Ic/ZVAvrrZHVCVH1ZESN2sTqSmnjNE76ty6NW+pZdVVeyWY1Wnk/q7Yg6kFWRI0Ksw6Xtik1mtc1po8RVbhWImoUoV9Rb7lTnh2AxbGScW/+kGuNKTv8S1cylQwcGALCknRFPtnpXlH57bfBhX+F4MrRb6lkn6jZb5GtoZwxIbgQJ9wm2rFUTzFyfJZLFfskpJtJpbFr+ml2myOilkrkIXTkQCRSupIVLFOfcgsT4pQC7utRZVGzO6bforQib6MxQc5P6aD6vYTjIurtJlq3WnJk6Fvqvc8StVSS9k7RZrl910XNlhyc+ZdUkXswpQalvnGrqKs9c/YomhpaJyPqjptJ2at+qfvVz6PkGyrZphmNi+SVuqKWgpSGbfljvVdU/Ucr1a7ao67GD8u7FjWdF2XnjcIS7ZgGl+okPpMI63BLmuZiQnhtji7t0ZVbFjXbVd6SJpIGKfQPqi+eLUmTHxWG/5S/S5iWbA8WbSDUOd1LPlb6aeno5RqO0far1fsAMqJap9l7v81WzBaICvGVvpNGoKe1/LRQh/eAqGAYRAWAhkBUAAMgKoABEBXAAIgKYABEBTAAogIYAFEBDICoAAZAVAADICqAARAVwACICmAARAUwAKICGABRAQyAqAAGQFQAAyAqgAEQFcAAiApgAEQFMACiAhgAUQEMgKgABkBUAAMg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Jggg==" alt="" />

2、存储过程统计,代码如下:

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;

输出结果

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXsAAAC6CAIAAADAn3r5AAAO9ElEQVR4nO2cS3LkuBFAeae+hO6iG/hKnll5o6vMchRhLybGtlbawgtNlynkB5kgiOLnvejoIEEQBCjlYwJF1VIAAGaxPLsDAHAjMA4AzAPjAMA8llLKx4rfjsSzb47Os+/KX3wAHIBs+CjGeVbXK347sHGefW8O9GOCm5MNn7MaZ1kWZ9evvJEj3KIj9AHg457G+dp2HGRt93GEW3SEPgB83ME4y4oSM8sE4yzL4uwGS+JHj/NjgpuTDZ/zGaesrPGQjhTQc40TKcE4cAGy4RMyzjqtqErU3SE4OU5EHItN9h5VyFu0Hri8nDVAVUkW8uZsu7sAY8iGT9s4VTipJR+tZ3IHkVmVlIgqlO2WWVPdIvUORO4GOQ5cgGz45IwjS+Yb569+rzId+b9aeRTSOFUaIu+JmqqodyyS4HxgHDgM2fBJzKrWu3J7vnGqHMfxjr+bxV/HcbTyyBAjTiHHgVOQDZ/EyrE/fZg/qyrhTGdv41Q3xLKJn+OoJrKshHHgIGTDJ/dZVfWU/jjArOrpOY6UwvrOxI0jDzkVMA4chGz4bFo5lmEmt7vJruNU5T7Z27SmGe2WL4KOjtxSjAMHIRs+IePIxF4+1Z0pQB8dxgnaZA/jWDmOVUetYNWRNTEOHIRs+Gx6A3CUXFTO8peclkeys6pHO5FUCOPAQciGzynfOX4ukcX1x65jZGdW1WznOD8muDnZ8ME4aY5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D4wDAPDAOAMwD4wDAPDAOAMzjf6sj0lQXHU5MAAAAAElFTkSuQmCC" alt="" />

二、按照条件查询记录个数

Select Count(*) from tablename where ID>1

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAbIAAADFCAIAAAC+QeCGAAANl0lEQVR4nO3cPY/ruBmGYf6M/Fy3Bzjt6adfbLX14kypaoMEQRAkcJXmAJsgWs9HMTOAU9Dm8OWXSIq2JOq+IBiyLMmURD/zSrJHffn67bxKX75+Y/CHEcCNqTXH4sc66DxauhUfHx8fxCJwB6uOxdMKfFixuIaWLN1hgP4RixOIRWBvUrGoLM6U4NPmsfiHRymVeJqeuc77+7uOxff394r25EwpasnSHQboXzQW7bDT4/4UZ2LzWAw0Vyln3J4SnMEfL2LHYro9mVNmtqRuWQD5smLRn3KfWPyfxS5d9VP7paLxInYsOi8563fEVjizJUt3GKB/0yfRC8bifyWllD1iAsh/KT1e5O3tTcfi29tbojH57zKzJUt3GKB/07dcggl4n1j8j0UpZR4T/KrNSC8YY8di8I2cFjoj/lvPbMnSHQboX9adaHNt0dSP94nF3y3BpLNf/d0TnFjKjsXEWzjv5bct3f78lizdYYD+1dxyMeEYnK1hLB49SqnEY3DmmV5fX3Usvr6+JtbvR16sGdWt0i1ZusMA/UvFol0eOhP9eZw5m8TivzzO2+kpzqM9c+JpJjsWYy2x1++3pEkzTEuW7jBA/2q+zt08AYO+fP32T4vJID2eeLQXSTzNZMdies5gG/zpdc0wLVm6wwD9W/WvXP7hUUrpR82eYh6dmWNPM728vOhYfHl5CbbHrDbYBmee6maYlizdYYD+rToW/+ZRSjmPzvQ0f4WTnp+fdSw+Pz87LfEbkGhb7GlpS5buMED/Vh2Lf/UopZxHPWLGE3Lm8dmxmLnmdHvqmmFasnSHAfq36lj8ywo8PT3pWHx6elpDS5buMED/Vh2Lf14BOxbX0JKlOwzQv1XHIgMDA8P9h/XGIgAsglgEAIFYBABBxOJPP//CwMDAsPPBjcUlohkAVoRYrJfzw/DY723Sa7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UYhHozBr/g45SquHa7uDx8XHpJgBopuwkOnYZTsfivxshFgEsqDgWg8lILC7dBADN1MSin4x1saiU2lAsmm33XyIWgZ5UxqKTjBWxqFeylVi0m+Q3j1gEelIfi3Yydl8tEovAfsyKRZOMxOJ9mwPghqgWsxCLwH4sdm2RWASwTtyJzkIsAvux2PcWTcJuIhbPfEEH2A1+5dIAsQj0pOV/0CEWAXRgjf9BRyn1uDXLHUEAjbX5DzoA0A1iEQAEYhEABGIRAARiEQAEYhEABGIRAARiEQAEYhEABGIRAARiEQAEYhEABGIRAARiEQAEYhEABGIRAARiEQAEYhEABGIRAARiEQAEYhEABGIRAARiEQAEYhEABGIRAARiEQAEYhEABGIRAARiEQAEYhEABGIRAARiEQAEYhEABGIRAARiEQAEYhEAhP8Dt76XQ/GNEHcAAAAASUVORK5CYII=" alt="" />

三、查询一个用户下所有表的记录总条数

declare
v_count number(10);
t_count number(10) default 0;
cursor t_cur is
select table_name
from user_tables;
begin
for t_rec in t_cur
loop
execute immediate 'select count(*) from '||t_rec.table_name||' into v_count';
t_count:=v_count+t_count;
end loop;
dbms_output.put_line(to_char(t_count));
end;

参考文章

1. badkano. 如何在oracle数据库中查询记录总条数

2. fight2009, owl1230. oracle数据库中如何查询一个用户下所有表的记录总条数

上一篇:FoxPro 数据库文件及记录命令


下一篇:python利用socketserver实现并发套接字功能