Vous êtes sur la page 1sur 19

ORACLE FUNCTIONS

Function make the result of query easiear and are used to manipulate the data
values. Functions make the basic query block more powerful. Function can
accept any no of constant value or variable , these variable or constant are
called as arguments.

ORACLE function are divided into two categories:

 Single row function


 Multiple row function

 SINGLE ROW FUNCTION:


It operates on single rows only and returns
one result per row. These function are used to manipulate data items.
They accept one or more arguments and return one value for each row
returned by query.
It can be classified in the following categories:
1. Character
2. Number
3. Date
4. General function
5. Conversion function

 CHARACTER:- It accept character data as input and can return both


character and number values.

ASCII(String):- it gives ascii value of the character.


CHR:- It returns the character equivalent to decimal value.

CONCAT:- It concatenates the two values.

INSTR:- It returns numeric position of the character.


LENGTH:-
It returns the numeric value of the given string.

LPAD:- This function allows you to pad the left side of a column
with any set of characters.
RPAD:-
This function allows you to pad the right side of a column
with any set of characters
LTRIM:- This function enables you to trim the left character of
the string.

Syntax:- LTRIM(<STRING>,<TRIM CHRACTER>)


FROM TABLE NAME;
RTRIM:- This function enables you to trim the left character of the
string
Syntax: - RTRIM(<STRING>,<TRIM CHRACTER>) FROM
TABLE NAME;

REPLACE:- It replace the older character value with the new one.
SUBSTR:- The substr functions allows you to extract a substring from
a string.

CASE CONVERSION:-

INITCAP:- This function returns the string with the first letter of
each word in uppercase.
UPPER:- This function converts string to all upper case.

LOWER:-This function converts string to all lower case.

TRANSLATE:-

The translate function replaces a sequence of characters in a string with


another set of characters. However, it replaces a single character at a time.
NUMERIC FUNCTION:
The numeric function accept numeric input and return numeric
value.

 ABSOLUTE:-
It gives the absolute value of a given input value.

 CEIL:- This function returns the next highest integer.


SIN/COS:-

It gives the value of trigonometric function like sin or cos.

 EXPONENT:-

It returns the exponent value of the given numeric value.


 FLOOR:- This function returns the next smallest integer.

 MOD:-

It gives the reminder value of m divided by n.

 POWER:-
 SIGN:- it gives sign.

 SQRT:- It gives the square root value of given number.

 TRUNCATE:-
This function truncates or chops off digits of precision from a number.

Syntax:- TRUNC(COLUMN|EXPRESSION,N)
DATE FUNCTION:

 SYSDATE:-

It returns the current date of the system.

LAST DAY:- It returs the last day of the date’s months.


MONTH BETWEEN:- returns the total months between the dates.

NEXT DAY:-
GENERAL FUNCTION:

 GREATEST NUMBER:-
It returns the maximum value among all given values.

 LEAST NUMBER:-

It returns smallest number among all given number.


 USER,UID:-

This function return the user name and user id.


AGGREGATE FUNCTION:

These function are used to produce summerised results , they are


applied on set of rows to give serial values. These function are called
group function.

 COUNT:- function counts the number of rows in the table, including


duplicate values and those with null values.

 SUM/AVG:-

It returns the sum or avg value of the given selected column.


 MIN/MAX:-
It returns the min/max value of a given selected column

Syntax:- SELECT MIN<COLUMNNAME> FROM TABLE NAME;


GROUPING DATA BY GROUP BY CLAUSE:
It is used to group the data in other words it divides row in table into smallest
groups. We can often used group function to return summary information for
each group. If no group by clause is specified then the default grouping is entire
result set.

GROUP BY CLAUSE:-

Vous aimerez peut-être aussi