Home

You are most welcome to share your knowledge with me, send your comments about this training.

SQL QUERIES

Monday, 5 January 2015

Replace Function In Oracle




Trim :- Removes leading and /or trailing blanks(or other characters ) from a string.
Syntax:- TRim([[<trim_spec >] char ]

SQL> select trim(' Aptech Computer') from dual;


Returns the following result.

TRIM('APTECHCOM
---------------
Aptech Computer


Concate Function:--

The syntax for the oracle concat function is :
concat(string1,string2)

Parameters Or Arguments.

String1 is the first string to concatenate.
string2 is second string to concatnate....

SQL> select concat(trim(' 'from'Nikita_sharma '),'Good Morning') from dual;

CONCAT(TRIM(''FROM'NIKITA
-------------------------
Nikita_sharmaGood Morning


Length
Syntax
Length(char)
{fn length(char)}
Returns the length in characters of the string argument char.if the char has the datatype CHAR ,the length includes all trailing blanks.
if a char is null ,it returns null.

SQL> select length('Australia') from dual;

LENGTH('AUSTRALIA')
-------------------
9


SQL> select concat(trim(' 'from'Nikita_sharma '),'Good Morning') from dual;

CONCAT(TRIM(''FROM'NIKITA
-------------------------
Nikita_sharmaGood Morning


Replace function replaces a sequence of characters in a string with another set of characters.

The syntax for the oracle sql replace function is:-
Replace(string1,string_to_replace,[replacement_string])


SQL> select replace('software','o','@') from dual;

REPLACE(
--------
s@ftware

No comments:

Post a Comment