產生oracle大量資料的sql語句

2021-09-09 05:39:31 字數 836 閱讀 3623

建立1100000行測試資料的的測試表

create table testtable12 as

select rownum as id,

to_char(sysdate + rownum/24/3600, 'yyyy-mm-dd hh24:mi:ss') as inc_datetime,

trunc(dbms_random.value(0, 100)) as random_id,

dbms_random.string('x', 20) random_string

from dual

connect by level <= 11000000(資料行數);

如果上面的資料行數不夠,而且擴大行數的時候記憶體報錯可以在上面的基礎上使用下面的語句。

declare

w_row int;

begin

w_row:=1100001;

for w_row in reverse 1100001 .. 1111111111 loop

insert into testtable1 (id, inc_datetime, random_id,  random_string) values

(w_row

,to_char(sysdate + 1/24/3600, 'yyyy-mm-dd hh24:mi:ss'),

trunc(dbms_random.value(0, 100)),  dbms_random.string('x', 20) );

if mod(w_row,100000)=0 then

commit;

end if;

end loop;

end;

Oracle 插入大量資料

2.假如tab1表中的沒有資料的話 drop table tab1 create table tab1 as select from tab2 然後在建立索引 3.用hint 提示減少操作時間 4.採用不寫日誌及使用hint提示減少資料操作的時間。建議方案是先修改表為不寫日誌 sql alter t...

Oracle 插入大量資料

2.假如tab1表中的沒有資料的話 drop table tab1 create table tab1 as select from tab2 然後在建立索引 3.用hint 提示減少操作時間 4.採用不寫日誌及使用hint提示減少資料操作的時間。建議方案是先修改表為不寫日誌 sql alter t...

Oracle 插入大量資料

2.假如tab1表中的沒有資料的話 drop table tab1 create table tab1 as select from tab2 然後在建立索引 3.用hint 提示減少操作時間 4.採用不寫日誌及使用hint提示減少資料操作的時間。建議方案是先修改表為不寫日誌 sql alter t...