Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 在oracle中,如何从存储过程将数据从一个表插入到另一个表?_Sql_Oracle_Plsql - Fatal编程技术网

Sql 在oracle中,如何从存储过程将数据从一个表插入到另一个表?

Sql 在oracle中,如何从存储过程将数据从一个表插入到另一个表?,sql,oracle,plsql,Sql,Oracle,Plsql,我的Oracle数据库中有一个每日表和一个历史表。在每天结束时,我希望将数据从daily表插入history表,然后截断daily表。问题是我必须插入5000个条目的数据块,我们总共要处理大约500万个条目。我对PL/SQL非常陌生,需要一些帮助来编写适用于此场景的存储过程 使用“一次完成”方法的第一个过程如下所示: create or replace procedure test is ts timestamp := current_timestamp; begin insert in

我的Oracle数据库中有一个每日表和一个历史表。在每天结束时,我希望将数据从daily表插入history表,然后截断daily表。问题是我必须插入5000个条目的数据块,我们总共要处理大约500万个条目。我对PL/SQL非常陌生,需要一些帮助来编写适用于此场景的存储过程

使用“一次完成”方法的第一个过程如下所示:

create or replace procedure test
is ts timestamp := current_timestamp;

begin
   insert into t_history
   select t.*, substr(USER, 1, 15), ts
   FROM t;
end test;
我的问题是,我如何重构上述方法,以5000个条目为单位加载数据,并在每次插入后提交,而不是一次全部提交


非常感谢您的帮助。

限制
获取
结合起来可能会有所帮助。更多信息:

Hi,您是否尝试过SQL,并看到它花费了多少时间,t_history表是否已分区。如果您使用的是11g及其后版本,那么最好在日期对t_历史表进行间隔分区。尝试使用/*+APPEND*/hint,看看它是否可以提高性能。为什么必须限制它?这是人为的“要求”。吃一整块披萨,还是一块被切成八片的披萨,需要更多的时间?