在PL/SQL中生成随机字符串(oracle 12c)
我试图使用PL/SQL生成一个随机字符串,其中只有2个固定单词。这是可能的吗?这就是你要找的吗在PL/SQL中生成随机字符串(oracle 12c),oracle,plsql,oracle12c,Oracle,Plsql,Oracle12c,我试图使用PL/SQL生成一个随机字符串,其中只有2个固定单词。这是可能的吗?这就是你要找的吗 SQL> with 2 -- two fixed words 3 test as 4 (select 'fixed words' col from dual), 5 -- split them to rows 6 inter as 7 (select level lvl, regexp_substr(col, '.', 1, level) let
SQL> with
2 -- two fixed words
3 test as
4 (select 'fixed words' col from dual),
5 -- split them to rows
6 inter as
7 (select level lvl, regexp_substr(col, '.', 1, level) let
8 from test
9 connect by level <= length(col)
10 )
11 -- aggregate them back, randomly
12 select listagg(let, '') within group (order by dbms_random.value(1, max_lvl)) result
13 from inter
14 join (select max(lvl) max_lvl from inter) on 1 = 1;
RESULT
--------------------------------------------------------------------------------
reiosdwxf d
SQL> /
RESULT
--------------------------------------------------------------------------------
fe ixoddrws
SQL> /
RESULT
--------------------------------------------------------------------------------
wdxeorsdfi
SQL>
你说只有两个固定词是什么意思?你能举个例子来更新这个问题吗?