Substr: The oracle substr function allows you to extract a substring .
SQL> select substr('santosh chaurasia',2,6) from dual;
SUBSTR
------
antosh
sql> select substr('priyaseth',4) from dual;
SUBSTR
------
antosh
SQL> select substr('avinashkare',-4) from dual;
SQL> select instr('nikita_sharma','k') from dual;
INSTR('NIKITA_SHARMA','K')
--------------------------
3
SQL> select instr('america','e') from dual;
The instr function in sql used to find the starting locatin of a pattern in a string.
The syntax for instr(str) is as follows.
instr(str,pattern,[starting position,[nth locatin]])
INSTR('AMERICA','E')
--------------------
3
SQL> select instr('nikitasony','n',2) from dual;-- for 2nd occurance
INSTR('NIKITASONY','N',2)
-------------------------
9
SQL> select lpad('vikram',10,'*') from dual;
LPAD('VIKR
----------
****vikram
SQL> select rpad('nasim',10,'*') from dual;
RPAD('NASI
----------
nasim*****
0 Comment to "Substr Function In Sql"
Post a Comment