Basic Functions in Oracle
Basic Functions in Oracle
What is a function?
Li
Types of functions
Li
Arithmetic functions
Li
Dual table
Li
Date arithmetic
Li
Date functions
Li
Summary
Li
Exercises
What is a function?
A function is similar to an operator in operation. A function is a name that performs a specific task. A function
may or may not take values (arguments) but it always returns a value as the result. If function takes values then
these values are to be given within parentheses after the function name. The following is the general format of a
function.
Types of functions
Functions are classified based on the type of data on which they perform the operation. The following are the
different types of functions available in Oracle.
Li
Arithmetic Functions.
Li
Li
String functions.
Li
Conversion functions.
Li
Miscellaneous functions.
Li
Group functions.
Arithmetic functions perform take numeric data; date functions take date type data and string functions take
strings. Conversion functions are used to convert the given value from one type to another. Miscellaneous
functions perform operations on any type of data. Group functions are used to perform operations on the groups
created by GROUP BY clause.
Note: Group functions or aggregate functions perform their operation on a group (a collection of rows). All the
remaining functions are called as single-row functions as they return a result for each row.
Arithmetic Functions
Arithmetic functions take numbers and perform arithmetic operations. Table 1 lists the arithmetic functions
available in Oracle.
Function
Description
ABS(value)
CEIL(value)
FLOOR(value)
MOD(value,divisor)
POWER(value,exponent)
ROUND(value[,precision])
TRUNC(value[,precision])
SQRT(value)
SIGN(value)
Function
Result
ROUND(1295.356,2)
1295.36
TRUNC(1295.356,2)
1295.35
ROUND(1295.356,0)
1295
ROUND(1285.356, -1)
1290
TRUNC(1285.356, -1)
1280
ROUND(1295,-2)
1300