User Tools

Site Tools


regular_expressions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
regular_expressions [2018/12/08 12:49] – created 0.0.0.0regular_expressions [2019/09/27 07:56] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== Regular_Expressions ====== 
- 
 Oracle can do almost as much as Perl but it's not quite there yet! Oracle can do almost as much as Perl but it's not quite there yet!
  
-Select a piece out of a long filename: 
-<code>0@@</code> 
 This will pick out the date part of the filename. This will pick out the date part of the filename.
 +<code>
 +string := '/oracle/export/MOCMMSP2/expdp_DEV2_D_FULL_20130131210003_01.dmp.gz';
 +
 +select regexp_substr(
 +,      string,
 +,      '(\_)([[0-9]]+)(\_)'   --<-- expression with subexpressions
 +,      1                    --<-- starting position
 +,      1                    --<-- nth occurrence
 +,      'i'                  --<-- match parameter (ignore case)
 +,      2                    --<-- 11g: subexpression to return
 +,      )
 +from   dual
 +</code>
 +
 +Pick out the file number. This expression will work with all these combinations. Useful for automating the addition of datafiles to the tablespace.
 +<code>
 +/cln/exp/ora_data2/clne/data2/ts_thaler_data_05.dbf
 +/cln/exp/ora_data2/clne/data2/ts_thaler_data_04.dbf
 +/cln/exp/ora_data2/clne/data2/ts_thaler_data_03.dbf
 +/cln/exp/ora_data2/clne/data2/ts_thaler_data_2.dbf
 +/cln/exp/ora_data2/clne/data3/ts_thaler_data100.dbf
 +/cln/exp/ora_data2/clne/data3/ts_thaler_data99.Dbf
 +/cln/exp/ora_data2/clne/data3/ts_thaler_data_98.DBF
 +/cln/exp/ora_data2/clne/data2/ts_thaler_data97.dbF
 +/cln/exp/ora_data2/clne/data2/ts_thaler_data_96.dbf
 +</code>
 +<code>
 +select regexp_substr(file_name,'(\d+)(\.dbf)',1,1,'i',1) file_number
 +from   dba_data_files
 +where  tablespace_name = 'TS_THALER_DATA'
 +/
 +</code>
 +
 +=== References ===
 +[[http://www.oracle-developer.net/display.php?id=508|oracle-developer.net]]
  
-====References==== 
-[[http://www.oracle-developer.net/display.php?id=508 oracle-developer.net]] 
regular_expressions.1544273361.txt.gz · Last modified: 2018/12/08 12:49 by 0.0.0.0

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki