在Oracle中,可以使用循环插入数据。以下是一个示例:,,“sql,DECLARE, i NUMBER := 1;,BEGIN, FOR r IN (SELECT * FROM your_table) LOOP, INSERT INTO your_target_table (column1, column2, column3), VALUES (r.column1, r.column2, r.column3);, i := i + 1;, IF i >= 100 THEN, COMMIT;, i := 1;, END IF;, END LOOP;,END;,/,“
DECLARE
CURSOR employee_cursor IS
SELECT employee_id, first_name, last_name, department_id
FROM source_table;
employee_rec employee_cursor%ROWTYPE;
BEGIN
OPEN employee_cursor;
LOOP
FETCH employee_cursor INTO employee_rec;
EXIT WHEN employee_cursor%NOTFOUND;
在这里可以对employee_rec进行处理,例如验证数据或转换格式
INSERT INTO EMPLOYEE_TABLE (EMPLOYEE_ID, FIRST_NAME, LAST_NAME, DEPARTMENT_ID)
VALUES (employee_rec.employee_id, employee_rec.first_name, employee_rec.last_name, employee_rec.department_id);
END LOOP;
CLOSE employee_cursor;
END;