This SQL Tutorial provides you a summary of some of the most common Oracle Scalar Functions. For this lesson’s exercises, use this link.
Oracle Scalar Functions allow you to perform different calculations on data values. These functions operate on single rows only and produce one result per row. There are different types of Scalar Functions, this tutorial covers the following:
- String functions – functions that perform operations on character values.
- Numeric functions – functions that perform operations on numeric values.
- Date functions – functions that perform operations on date values.
- Conversion functions – functions that convert column data types.
- NULL-related Functions – functions for handling null values.
Note: this tutorial focuses on Oracle Scalar Functions; for more details about Group Functions, use this link.
Oracle String Functions
|
Syntax |
Description |
Function |
|
Returns text strings concatenated |
CONCAT |
|
Returns the location of a substring in a string. |
INSTR |
|
Returns the number of characters of the specified string expression. |
LENGTH |
|
Returns a character string after truncating all trailing blanks. |
RTRIM |
|
Returns a character expression after it removes leading blanks. |
LTRIM |
|
Replaces all occurrences of a specified string value with another string value. |
REPLACE |
|
Returns the reverse order of a string value. |
REVERSE |
|
Returns part of a text. |
SUBSTR |
|
Returns a character expression after converting uppercase character data to lowercase. |
LOWER |
|
Returns a character expression with lowercase character data converted to uppercase. |
UPPER |
|
Returns a character expression, with the first letter of each word in uppercase, all other letters in lowercase. |
INITCAP |
Oracle Date Functions
| Syntax |
Description |
Function |
|
Returns a specified date with additional n months |
ADD_NONTHS |
|
Returns the value of a specified date. |
EXTRACT |
|
Returns a date representing the last day of the month for specified date. |
LAST_DAY |
|
Returns the count of months between the specified startdate and enddate |
MONTHS_BETWEEN |
|
returns the first weekday that is greater than the specified date. |
NEXT_DAY |
|
Returns the current database system date. This value is derived from the operating system of the computer on which the instance of Oracle is running. |
SYSDATE() |
Oracle Numeric Functions
|
Syntax |
Description |
Function |
|
Returns an integer that is less than or equal to the specified numeric expression. |
TRUNC |
|
Returns an integer that is greater than, or equal to, the specified numeric expression. |
CEIL |
|
Returns a numeric value, rounded to the specified length or precision. |
ROUND |
Oracle Conversion Functions
|
Syntax |
Description |
Function |
|
Converts a date or number to a string |
TO_CHAR |
|
Converts a string value to a date |
TO_DATE |
|
Converts a string value to a number |
TO_NUMBER |
Oracle NULL-Related Functions
|
Syntax |
Description |
Function |
|
Replaces NULL with the specified replacement value. |
NVL |