Oracle String Function

String Function

Overview

  •  

String Function

String Manipulation Functions

1. CONCAT :- 

  • Purpose: Concatenates two strings.
  • Syntax: CONCAT(string1, string2)
  • Example :- Select concat(‘Hello’,’World’) AS result from dual;  

TRY YOURSELF

String Manipulation Functions

2. SUBSTR :- 

  • Purpose: Extracts a substring from a string.
  • Syntax: SUBSTR(string, start_position, length)
  • Example :- select substr(‘Oracle10g’,1,6) as result from dual; 

TRY YOURSELF

String Manipulation Functions

3. INSTR :- 

  • Purpose: Returns the position of a substring within a string.
  • Syntax: INSTR(string, substring, [start_position], [occurrence])
  • Example :- select Instr(‘Oracle10g’,’10’) as result from dual;

TRY YOURSELF

String Manipulation Functions

4. REPLACE :- 

  • Purpose: Replaces occurrences of a substring within a string.
  • Syntax: REPLACE(string, search_string, replacement_string)
  • Example :- select replace(‘oracle10g’,’10’,’11’) as result from dual;

TRY YOURSELF

String Manipulation Functions

5. LTRIM :- 

  • Purpose: Removes leading characters from a string.
  • Syntax: LTRIM(string, trim_string)
  • Example :- select ltrim(‘                            Hello World’) as result from dual;

TRY YOURSELF

String Manipulation Functions

6. RTRIM :- 

  • Purpose: Removes trailing characters from a string..
  • Syntax: RTRIM(string, trim_string)
  • Example :- select rtrim(‘Hello world                            ‘) as result from dual;

TRY YOURSELF

String Manipulation Functions

7. TRIM :- 

  • Purpose: Removes leading and trailing characters from a string.
  • Syntax: TRIM([LEADING|TRAILING|BOTH] trim_char FROM string)
  • Example :- select trim (‘                  Hello World                           ‘ ) as result from dual;

TRY YOURSELF

String Manipulation Functions

8. LENGTH :- 

  • Purpose: Returns the length of a string.
  • Syntax: LENGTH(string)
  • Example :-  select length(‘WELCOME TO ORACLE 10G’) as result from dual;

TRY YOURSELF

String Manipulation Functions

9.  ASCII :- 

  • Purpose: Returns the ASCII value of the first character of a string.
  • Syntax: ASCII(character)
  • Example :- select ascii(‘A’) as result from dual;

TRY YOURSELF

String Manipulation Functions

10. CHR :- 

  • Purpose: Returns the character corresponding to an ASCII value.
  • Syntax: RTRIM(string, trim_string)
  • Example :- select chr(’97’) as result from dual;

TRY YOURSELF

String Manipulation Functions

11. UPPER :- 

  • Purpose: Converts a string to uppercase.
  • Syntax: UPPER(string)
  • Example :- select upper(‘hardik kabra’) as result from dual;

TRY YOURSELF

String Manipulation Functions

12. Lower :- 

  • Purpose: Converts a string to lowercase.
  • Syntax: LOWER(string)
  • Example :- select lower(‘HARDIK  KABRA’) as result from dual;

TRY YOURSELF

String Manipulation Functions

13. INIT :- 

  • Purpose: Converts the first letter of each word in a string to uppercase.
  • Syntax: INITCAP(string)
  • Example :- select initcap(‘hardik Kabra’) as result from dual;

TRY YOURSELF

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.