--查询指定用户名下的表的记录数 select NUM_ROWS,TABLE_NAME from dba_all_tables where owner='用户名' order by NUM_ROWS desc
--删除重复的记录 delete from onetable where guid in(select guid from onetable group by guid Having count (guid)>1) and rowid not in(select min( rowid ) from onetable group by guid Having count (guid)>1)
CREATE OR REPLACE PROCEDURE GETRECORDFROMPAGE(
tblName in varchar2, -- 表名
fldName in varchar2:='*', --显示列
PageSize in number := 20, -- 页尺寸
PageIndex in number := 1, -- 页码
strOrderSyntax in varchar2, ---排序的具体语法
strWhere in varchar2 := '', -- 查询条件 (注意: 不要加 where)
Onlyzd in varchar2 :='*',--唯一字段
Total in out number,
cur_OUT OUT sys_refcursor
)
as
tempSql varchar2(8000):='';
countSql varchar2(2000):='';
strSql varchar2(8000):='';
condition varchar2(1000):=strWhere;
fieldsName varchar2(1000):='';
begin
if condition='' or condition is null then
condition := '1=1';
end if;
fieldsName := trim(fldName);
if fieldsName != '*' then -- 不为 '*'
tempSql := 'select '|| fldName ||' from '||tblName||' where '||condition||' '||strOrderSyntax;
else
tempSql := 'select a.* from '||tblName||' a where '||condition||' '||strOrderSyntax;
end if;
--记录集
strSql := 'select t.*,rownum as num from ('||tempSql||') t ';
strSql := 'select * from ('|| strSql ||') tt where tt.num<='||CAST((PageSize*PageIndex) AS char)||' and tt.num>'||CAST((PageSize*(PageIndex-1)) AS char);
--为了排序,重新组织语句
--strSql := 'select * from ('|| strSql||') tt '||strOrderSyntax;
--记录总数
countSql := 'select DISTINCT '||Onlyzd||' from '||tblName||' where '||condition;
countSql := 'select count(*) as Total from ('|| countSql ||') t';
execute immediate countSql into Total;
OPEN cur_OUT FOR strSql;
END GETRECORDFROMPAGE;
--创建表空间 create tablespace HzjwUiasDB logging datafile 'd:\DBRunfile\HzjwUiasDB.dbf' size 1024M autoextend on next 512M maxsize 20480M extent management local;