有两个表table_abc和table_xyz
table_abc
:
EXPIRATION_DATE
ISSUE_DATE
ISSUING_AUTHORITY
ISSUING_COUNTRY
ISSUING_LOCATION
LEGISLATION_CODE
NUMBER
TYPE
table_xyz
:
EXPIRATION_DATE
ISSUE_DATE
ISSUING_AUTHORITY
ISSUING_COUNTRY
ISSUING_LOCATION
LEGISLATION_CODE
NUMBER
TYPE
PERSON_NO
现在我必须将table_abc中的所有数据导入table_xyz
为此,我应该编写这个简单的SQL:
INSERT INTO table_xyz
(column_name(s))
SELECT column_name(s)
FROM table_abc ;
或者我尝试编写如下的plsql过程:
Cursor cursor_abc
SELECT * FROM table_abc;
--PL/SQL Table to store the data temporarily
TYPE abc_tab_type
IS
TABLE OF table_abc%ROWTYPE INDEX BY PLS_INTEGER;
abcTAB abc_tab_type;
BULK_ERRORS EXCEPTION;
PRAGMA EXCEPTION_INIT (BULK_ERRORS, -24381);
BEGIN
OPEN cursor_abc;
LOOP
FETCH cursor_abc BULK COLLECT INTO abcTAB ;
FORALL I IN 1..abcTAB.COUNT
INSERT
INTO table_xyz
(
column names
)
SELECT column ames
FROM table_abc
EXIT WHEN CURSOR_abc%NOTFOUND;
END LOOP;
CLOSE CURSOR_abc;
END;
此代码在insert:
行上抛出错误PLS-00435:没有BULK In-BIND的DML语句不能在FORALL中使用
我必须为26个表做这个..所以我想要一个更优化的性能解决方案
答案 0 :(得分:1)
INSERT INTO table_xyz
(column_name(s))
SELECT column_name(s)
FROM table_abc ;
如果列订单及其数据类型相同,将为您完成工作。或者甚至可以在创建表table_xyz时执行此操作。
有些事情:
CREATE TABLE table_xyz AS
SELECT * from table_abc WHERE 1=1
;
首先,将使用table_abc中的所有列名创建table_xyz,然后将table_abc中的值复制到table_xyz