REGEXP_SUBSTR函數格式如下: REGEXP_SUBSTR(source_char, pattern [, position [, occurrence [, match_param [, subexpr ] ] ] ] )
-
source_char
is a character expression that serves as the search value. It is commonly a character column and can be of any of the data typesCHAR
,VARCHAR2
,NCHAR
,NVARCHAR2
,CLOB
, orNCLOB
. -
pattern
is the regular expression. It is usually a text literal and can be of any of the data typesCHAR
,VARCHAR2
,NCHAR
, orNVARCHAR2
. It can contain up to 512 bytes. If the data type ofpattern
is different from the data type ofsource_char
, then Oracle Database convertspattern
to the data type ofsource_char
. For a listing of the operators you can specify inpattern
, refer to Appendix D, "Oracle Regular Expression Support". -
position
is a positive integer indicating the character ofsource_char
where Oracle should begin the search. The default is 1, meaning that Oracle begins the search at the first character ofsource_char
. -
occurrence
is a positive integer indicating which occurrence ofpattern
insource_char
Oracle should search for. The default is 1, meaning that Oracle searches for the first occurrence ofpattern
.If
occurrence
is greater than 1, then the database searches for the second occurrence beginning with the first character following the first occurrence ofpattern
, and so forth. This behavior is different from theSUBSTR
function, which begins its search for the second occurrence at the second character of the first occurrence. -
match_parameter
is a text literal that lets you change the default matching behavior of the function. The behavior of this parameter is the same for this function as forREGEXP_COUNT
. Refer to REGEXP_COUNT for detailed information. -
For a
pattern
with subexpressions,subexpr
is a nonnegative integer from 0 to 9 indicating which subexpression inpattern
is to be returned by the function. This parameter has the same semantics that it has for theREGEXP_INSTR
function. Refer to REGEXP_INSTR for more information.
with t as (
select * from file_test a
where a.tpid = '110'
and instr(a.sqid, ',') > 0
)
select regexp_substr(t.sqid, '[^,]+', 1, level) sqid,t.filename,t.updatetime from t
connect by prior rowid = rowid
and prior dbms_random.value is not null
and level <= regexp_count(t.sqid, '[^,]+')
PRIOR
In a hierarchical query, one expression in the CONNECT
BY
condition
must be qualified by the PRIOR
operator. If the CONNECT
BY
condition
is compound, then only one condition requires the PRIOR
operator, although you can have multiple PRIOR
conditions. PRIOR
evaluates the immediately following expression for the parent row of the current row in a hierarchical query.
DBMS_RANDOM.VALUE Functions
The basic function gets a random number, greater than or equal to 0 and less than 1, with 38 digits to the right of the decimal (38-digit precision). Alternatively, you can get a random Oracle number x, where x is greater than or equal to low
and less than high
.
以此來防止出現循環。