Download presentation
Presentation is loading. Please wait.
1
Oracle SQL Built-in Functions
Chapter 5 in Lab Reference
2
Text Functions Concatenation operator ||
To concatenate column names with other column names or with literal characters. Example: Select name || ‘ has an id of ‘ || ssn From employee; NAME||’HAS AN ID OF'||SSN Jamil N.Samir has an id of Amani F.Zaki has an id of Jihan H.Walid has an id of Ramy S.Nabil has an id of Joyce A.Eman has an id of Ahmad V.Jabbar has an id of James B.Baher has an id of 7 rows selected. Built-in Functions
3
Column Alias Names Example: From employee; Select name AS Employee
Jamil N.Samir Amani F.Zaki Jihan H.Walid Ramy S.Nabil Joyce A.Eman Ahmad V.Jabbar James B.Baher 7 rows selected. Built-in Functions
4
Column Alias Names When you want to include spaces or special characters in alias names, then enclose the alias name in double quotation marks. Example: Select name || ' has an id of ' || ssn "Important information" From employee; Important information Jamil N.Samir has an id of Amani F.Zaki has an id of Jihan H.Walid has an id of Ahmad V.Jabbar has an id of James B.Baher has an id of 7 rows selected. Built-in Functions
5
Table Alias Names Example: Select T.item_id, T.item_desc From item T;
item_id item_desc LA Box, Small NY Bottle, Large Built-in Functions
6
Number Functions ROUND
The ROUND function rounds the value you want to modify. Example: Select product_name, product_price, ROUND(product_price,0) From product; product_name product_price ROUND(product_price,0) Roco Pencil FABER Pen Roco Pad Built-in Functions
7
Number Functions TRUNC
The TRUNC function truncates precision from a number. Example: Select product_name, product_price, TRUNC(product_price,0) From product; product_name product_price TRUNC(product_price,0) Roco Pencil FABER Pen Roco Pad Built-in Functions
8
Number Functions POWER
power(m,n) number m raised to the power of n. Example: Select power(salary,2) From employee where ssn= ; POWER(SALARY,2) Built-in Functions
9
Number Functions SQRT Select sqrt(salary) sqrt(n) Example:
returns square root of n. Example: Select sqrt(salary) From employee where ssn= ; SQRT(SALARY) Built-in Functions
10
Text Functions UPPER, LOWER & INITCAP
These three functions change the case of the text you give them. Example: Select UPPER(product_name) From product; Select LOWER(product_name) UPPER(product_name) ROCO PENCIL FABER PEN ROCO PAD LOWER(product_name) roco pencil faber pen roco pad Built-in Functions
11
Text Functions UPPER, LOWER & INITCAP
Example: Select INITCAP(product_name) From product; INITCAP(product_name) Roco Pencil Faber Pen Roco Pad Built-in Functions
12
Text Functions LENGTH To determine the lengths of the data stored in a database column. Example: Select product_name, LENGTH(product_name) AS “Name_Length” From Product where LENGTH(product_name)>8; product_name NAME_Length FABER Pen Roco Pencil Built-in Functions
13
Text Functions SUBSTR To separate multiple bits of data into discrete segments. Example: Select SUBSTR(item_id,1,2) Location, SUBSTR(item_id,4,3) Number, Item_desc From item; Location Number Item_desc LA Box, Small NY Bottle, Large Built-in Functions
14
Text Functions REPLACE
Replace(char, str1, str2) Every occurrence of str1 in char is replaced by str2. Example: Select Replace(name,'Jamil','Sara') From employee; REPLACE(NAME,'JAMIL','SARA') Sara N.Samir Amani F.Zaki Jihan H.Walid Ramy S.Nabil Joyce A.Eman Ahmad V.Jabbar James B.Baher 7 rows selected. Built-in Functions
15
Date Functions Function Description Syntax
Sysdate Get current system date and time. INSERT INTO employee VALUES (…………, trunc(sysdate),……….); Built-in Functions
16
Data Conversion Functions
Description To_char(input_value, format_code) Converts any data type to character data type. To_number(input_value, format_code) Converts a valid set of numeric character data to number data type. To_date(input_value, format_code) Converts character data of the proper format to date data type. Built-in Functions
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.