Wednesday 23 September 2020

Having fun with "for" loops in Linux

  >for i in {1..61}

> do

> for j in {01..12}

> do

> echo "create synonym us$i$j for usage_dummy;" >> 1.sql

> echo "create synonym au$i$j for accumulates_usage_dummy;" >> 1.sql

> done

> done


Friday 4 September 2020

How to find special characters in the DB

  Match nth character

SQL> select case when regexp_like('ter*minator' ,'^...[^[:alnum:]]') then 'Match Found' else 'No Match Found' end as output from dual;

Output: Match Found


In the above example we tried to search for a special character at the 4th position of the input string “ter*minator”

Let’s now try to understand the pattern '^...[^[:alnum:]]'

^ marks the start of the string
. a dot signifies any character (… 3 dots specify any three characters)
[^[:alnum:]] Non alpha-numeric characters (^ inside brackets specifies negation)

Note: The $ is missing in the pattern. It’s because we are not concerned beyond the 4th character and hence we need not mark the end of the string. (...[^[:alnum:]]$ would mean any three characters followed by a special character and no characters beyond the special character)



https://www.orafaq.com/node/2404