oracle儲存過程實現大資料量表的複製

2021-05-05 01:46:03 字數 1086 閱讀 9286

create or replace procedure tablebak

(p_table in varchar2,

p_tableback in varchar2)as

pragma autonomous_transaction;

n_insertfirst number:=0;

n_insertlast number:=10000;

n_insertall number:=0;

begin

select count(*) into allnumber from p_table;

while 1=1 loop

execute immediate

'create table as '||p_table||sysdata||_bak||' select * from '|| p_tablebak ||' where rownum <= n_insertlast and rownum > n_insertfirst '

if sql%notfound then

exit;

else

n_insertfirst:=n_insertlast;

n_insertlast:=n_insertlast + 10000;

if n_insertlast>n_insertall then

n_insertlast:=n_insertall;

end if;

commit;

end loop;

commit;

dbms_output.put_line('finished!');

end;

create or replace procedure p_tran_data  

as  

last_date date;  

begin  

select max(coldt) into last_date from tbnameb;  

insert into tbnameb select * from tbnamea where coldt > last_date;  

commit;

end;

Oracle大資料量分頁通用儲存過程

v sql select from select a.rownum rn from p sqlselect a where rownum to char v heirownum bwhere rn to char v lowrownum 注意對rownum別名的使用,第一次直接用rownum,第二次...

oracle儲存過程實現分頁

建立儲存過程 建立存放游標的包 create or replace package page package is 申明游標 type page cursor is ref cursor end page package 建立查詢所有使用者的過程 create or replace procedur...

oracle 儲存過程實現分頁

1 create or replace package pkg query is23 45 author administrator 6 created 2016 12 8 星期四 10 28 37 7 purpose 用做查詢游標89 10 public type declarations 11 ...