How to Use Functions in Oracle
The Oracle database supports dozens of functions. The majority of the functions are "scalar", or column, functions as opposed to "aggregate", or group
functions such as
count. In this topic I'll introduce you to a couple of useful scalar functions.
To learn how to use the functions in Oracle, follow these steps:
- You'll need to download and install Oracle 12c. The instructions for the setup can be found in How to use sample schemas. Follow steps 1 through 4 in this topic before proceeding to the next step.
- Let's presuppose we are required to combine the first name and last name of employees stored in the
Employeestable. First, we will issue an SQL*Plus statement to limit the column size on output for readability:
- We will combine first name and last name (with a white space separator) using the concatenation operator (
||) for department ID = 60:
- Imagine we are now directed to display the first character only of the first name:
Notice we have used the
substr(substring) function to display the substring beginning in position 1 of the first name for a length of 1.