9i以上可以通过Insert all语句完成,仅仅是一个语句,如:
INSERT ALL
WHEN (id=1) THEN
INTO TEST_1 (id, name)
values(id,name)
WHEN (id=2) THEN
INTO TEST_2 (id, name)
values(id,name)
ELSE
INTO TEST_3 (id, name)
values(id, name)
SELECT id,name
FROM a;
CREATE TABLE TEST_1(ID INT,NAME VARCHAR2(20));
CREATE TABLE TEST_2(ID INT,NAME VARCHAR2(20));
CREATE TABLE TEST_3(ID INT,NAME VARCHAR2(20));
CREATE TABLE A(ID INT,NAME VARCHAR2(20))
INSERT INTO A VALUES(1,'DDD');
INSERT INTO A VALUES(2,'EEE');
INSERT INTO A VALUES(3,'FFF');
SELECT * FROM TEST_1
1 DDD
SELECT * FROM TEST_2
2 EEE
SELECT * FROM TEST_3
3 FFF
阅读(1453) | 评论(0) | 转发(0) |