Explain any four string functions with example.

String functions along with examples are: 
i) Lower(char)- Returns the input string with all letters in lower case.
Example: SQL>Select lower (‘RAJESH’) from dual;
Output: rajesh
 
ii) Upper(char)-Returns the input string with all letters in upper case.
Example: SQL>Select upper (‘rajesh’) from dual;
Output: RAJESH 

iii) Ltrim(char,set)- It removes or trims from left of character string. 
Example: SQL>Select Ltrim(‘university’,’univ’) from dual;
Output: ersity 

iv) Rtrim(char,set)- It removes or trims from right of character string. 
Example: SQL>Select Rtrim(‘university’,’sity’) from dual;
Output: univer 

v) Length(char)-It returns length of character string. 
Example:SQL> Select length(‘University’) from dual;
Output:10 

vi) CONCAT(str1,str2,...)-Returns the string that results from concatenating the  arguments.
Example: Select Concat(‘employee’, ‘name’) from dual;
Output: employeename 

vii) LPAD(str, len, padstr)-Returns the string str, left-padded with the string padstr to a length of  len characters.
Example: Select lpad(ename,10.’*’) from emp where empno=7782; 

viii) RPAD(str,len,padstr)-Returns the string str, right-padded with the string padstr to a length of  len characters.
Example: Select rpad(ename,10.’*’) from emp where empno=7782; 

viii) Substr(Char,m,n)-It returns a portion of char, beginning at a character m, n character long.
Example: Select substr(‘College’,3,4) from dual;
Output: lleg 

Post a Comment

0 Comments