CREATE TABLE t (seqno NUMBER, a VARCHAR2(5), b VARCHAR2(5));
想要
INSERT INTO t VALUES (1, 'X', 'X');
(2, 'X', 'X')
(3, 'X', 'X')
...
(N+1, 'X', 'X')
只需要执行:
INSERT INTO t (seqno, a, b)
SELECT LEVEL + 1, a, b
FROM dual, t
CONNECT BY LEVEL <= &N
这个方法确实不错。
具体请看:
SQL> insert into t values(1, 'x', 'X');
已创建 1 行。
SQL> insert into t(seqno, a, b) select level+1, a, b from dual, t connect by lev
el<=&N
2 ;
输入 n 的值: 10
原值 1: insert into t(seqno, a, b) select level+1, a, b from dual, t connect
by level<=&N
新值 1: insert into t(seqno, a, b) select level+1, a, b from dual, t connect
by level<=10
已创建10行。