STRING Function
This function generates a random string.
DBMS_RANDOM.STRING()
opt IN CHAR,
len IN NUMBER)
RETURN VARCHAR2;
The first parameter specifies what the returning string looks like. Providing any other character will return the output in upper case only.
- 'u', 'U' - returning string in uppercase alpha characters
- 'l', 'L' - returning string in lowercase alpha characters
- 'a', 'A' - returning string in mixed case alpha characters
- 'x', 'X' - returning string in uppercase alpha-numeric characters
- 'p', 'P' - returning string in any printable characters.
The second parmaeter is the size of return string.
Exampels
1. Generating an upper case string of 10 characters
select dbms_random.string('U', 10) from dual;
HXUNQVAPMH
2. Generating a lower case string of 10 characters
select dbms_random.string('L', 10) from dual;
oelqemcuvc
3. Generating an alphanumeric string of 15 characters
select dbms_random.string('A', 15) from dual;
nTaZMOMozatqsXY
4.Generating an upper case alphanumeric string of 15 characters
select dbms_random.string('X', 15) from dual;
HBU7GFIGGH3MMDC
5.Generating a string of printable 100 characters
select dbms_random.string('P', 100) from dual;
/sJ(HQ1":[>uD>h#^gMDyT=:S7L++YZF^JX<?#Mf)[hWi2T,3{LT1`Zb+v3S+lIx'v2dA6jhD6|cfqFf3y`<;6)iBloKpv`0Sz=+