pl⼀sql插入1000条数据?

2025-03-23 04:31:08
推荐回答(2个)
回答1:

从表2批量插入表1
insert into 表1(字段1,字段2) select 字段a,字段b from 表2 where ...
如果是从外部程序连oracle插入的话,估计要写循环。

回答2:

dbms_random.string (opt char, len number);
--opt:表示返回值可能包含的东西
----'u','U' : 任何大写字母
----'l','L' : 任何小写字母
----'a','A' : 大小写混合字母
----'x','X' : 大写字母和数字混合
----'p','P' : 任何可打印字符
----其他参数 : 任何大写字母
--len:表示要返 回的字符串长度

declare
begin
for i in 1..1000 loop
insert into table(id,s) select i ,dbms_random.string('l',1) as s from dual;
end loop;
end;
试试,我没跑过…