create or replace function fn RETURN VARCHAR2 IS
label varchar2(24) := '';
BEGIN
-- abc~122~373~7777777~5367
select
chr(97 + floor(dbms_random.value*26)) || chr(97 + floor(dbms_random.value*26)) || chr(97 + floor(dbms_random.value*26))|| '~'
|| rpad(floor(dbms_random.value*123),3, '9') || '~'
|| rpad(floor(dbms_random.value*123),3, '8') || '~'
|| rpad(floor(dbms_random.value*1234567),7, '6') || '~'
|| rpad(floor(dbms_random.value*1234),4, '4') into label
from dual ;
RETURN label;
END;
你可以通過調用它來創建一個表,如下所示n
次。
create table testtable as select fn from dual connect by level <= 1000000000;
好的,那是什麼問題?閱讀https://docs.oracle.com/database/121/ARPLS/d_random.htm#ARPLS040 – OldProgrammer