Oracle_3
Oracle_3
It works or executes from each of value. The following are the single row functions.
A) Number Functions
B) String Functions
C) Date Functions
D) Conversion Functions
E) General Functions.
A) NUMBER FUNCTIONS:
i)Power: power(m,n):
it returns the m raised to the n’th power .It multiply the m specified in n number of times.
EX: select power(3,3)from dual;
o/p ……>27
ii)sqrt :
it returns the squre root of specified value.
EX: select sqrt(25) from dual;
iv)ABS (M):
it returns the absolute value of m
EX:- select abs(-25) from dual:
o/p→ 25 >it always displays the positive value.
v)trunc:-
trunc function returns number truncated to certain number of decimal places.
The function returns n1 truncated to n2 decimal places.
If n2 is omitted, then n1 truncated to ‘0’ places. n2 can be negative to truncate (make zero) n2 digits left
to the decimal points.
Ex: trunc (125.815)
O/P: 125
Trunc (125.815,0)
O/P : 125
Trunc (125.815,1)
O/P : 125.8
Trunc (125.815,2)
O/P : 125.81
Trunc (-125.815,2)
O/P: -125.81
Trunc (125.815,-1)
O/P : 120
Trunc (125.815,-2)
O/P : 100
vi) Round:
The round function returns a number rounded to a certain number of decimal places.
If parameter is omitted the function will round number to ‘0’ decimal places.
vii) Sign:
It returns the sign of specified number.
If number is less than zero output is ‘-1’
If number is zero then output is ‘0’
If number is more than zero output is ‘1’
viii) Ceil :
It returns the smallest integer greater than or equal to m
The adjustment is done to the highest nearest decimal place.
Ex: select ceil (14.27) from dual;
O/P : 15
iX) Floor:
It returns the largest integer less than or equals to m, The adjustment should done to the lowest nearest
value.
Ex: select floor (14.27) from dual;
O/P : 14
Select floor (14.99) from dual;
O/P : 14
X) ASCII :
This function returns the number code for the specified number.
Ex: select ASCII (‘t’) from dual;
O/P: 116
Xi) CHR :
It returns the character based on number code.
Ex: select chr (116) from dual;
O/P: ‘t’
B. String functions:
i) Length:
Length function gives the length of character.
Ex: select length (‘Alexander’) from dual;
O/P: 7
ii) Reverse:
It is used to reverse the given string
Ex: select reverse (‘Alexnader’) from dual;
iii. Upper:
It converts the given string to upper letters.
Iv: Lower:
It converts the given string to lower letters.
V. Initcap:
It converts the given string initial letter to upper letter and remaining characters to lower letter.
Vi. Concat:
It is used to join the two strings.
We can only join two strings.
Vii. Substr :
Substr function returns specified characters from character value starting from position m to n
characters.
Syn: substr( expression,m,n)
It searches for expression beginning with mth character for nth occurrence and returns the numeric
position of substring.
m can be positive or negative.If it is negative searches in backword direction from end of the expression.
n always be positive.
Examples:
Select instr (‘orporatororders’ ‘or’) from dual;
O/P: 2
iX) Trim:
It trims the leading or trailing or both characters from string.
If we specify it trim only the leading characters.
If we specify trailing it trim only the trailing characters.
If we don’t specify leading /trailing/both, the trim function will remove characters from both front and
end of string
Syntax: trim (leading | heading |both, ’character’ from ‘string’);
Ltrim (‘0001230’,’0’)
O/P: 1230
Ltrim (‘6372tech1234’,’0123456789’)
O/P: tech1234
In the above example every number combination from 0-9 has been listed in the string parameter.
By doing this it does not only for order that appears the string, all leading number will be removed.
Xi. Rtrim:
It removes the specified characters from right of specified string.
Ltrim (‘0012300’,’0’)
O/P: 00123
Ltrim (‘6372tech1234’,’0123456789’)
O/P: 6372tech
Xii. Lpad:
The Lpad function pads (adds) the specified characters to the left side of the string.
Padà this is the characters that will be characters padded to the left side of the string.
If we don’t specify any characters to be pad by default it will pad the spaces.
The Rpad function pads (adds) the specified characters to right of the specified string
Xiv. Translate:
XV. Replace:
This function replaces a sequence of characters in a string with another set of characters.
Syntax: replace (string-name, ‘string to replace’, ‘and replacement string’)
If we don’t specify replacement string , the replace function simply remove all occurrences of string and
give us the result output
Replace (‘123tech324’,’123’,’456’)
O/P: 456tech324