Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
all labs.pdf
Скачиваний:
74
Добавлен:
25.02.2016
Размер:
2.04 Mб
Скачать

Objectives

After completing this lesson, you should be able to do the following:

Describe various types of functions available in SQL

Use character, number, and date functions in SELECT statements

Objectives

Copyright © 2009, Oracle. All rights reserved.

Academy

 

 

 

 

 

Oracle

Functions make the basic query block more powerful, and they are us d to manipulate data values. This is the first of two lessons that explore functions. It focuses on single-row character, number, and date functions.

&

Only

Internal

 

Use

Oracle

 

Oracle Database 11g: SQL Fundamentals I 3 - 2

Lesson Agenda

Single-row SQL functions

Character functions

Number functions

Working with dates

Date functions

 

Copyright © 2009, Oracle. All rights reserved.

Academy

 

 

 

 

Oracle

&

Only

 

 

Internal

 

 

 

 

Use

 

Oracle

 

 

 

Oracle Database 11g: SQL Fundamentals I 3 - 3

SQL Functions

Input

Output

Function

arg 1

Function performs

 

action

arg 2

Result

 

 

value

arg n

SQL Functions

Copyright © 2009, Oracle. All rights reserved.

Academy

 

 

 

 

• Format dates and numbers for display

Oracle

 

Functions are a very powerful feature of SQL. They can be used to do the following:

 

• Perform calculations on data

 

 

 

 

 

• Modify individual data items

 

 

 

 

 

• Manipulate output for groups of rows

 

Only

 

 

• Convert column data types

&

 

 

 

 

 

 

 

 

 

 

 

Internal

 

 

 

 

SQL functions sometimes take arguments and always return a value.

 

(11.1).

 

Use

 

Note: If you want to know whether a function is a SQL:2003 compliant function, refer to the Oracle Compliance To Core SQL:2003 section in Oracle Database SQL Language Reference 11g, Release 1

Oracle

Oracle Database 11g: SQL Fundamentals I 3 - 4

Two Types of SQL Functions

Functions

Single-row

functions

Multiple-row

functions

Return one result

Return one result

per row

per set of rows

Two Types of SQL Functions

 

Academy

Copyright © 2009, Oracle. All rights reserved.

 

There are two types of functions:

Single-row functions

Multiple-row functions

Single-Row Functions

Oracle

 

 

&

These functions operate on single rows only and return o e resu t per row. There are different types

of single-row functions. This lesson covers the followingOnlyo es:

• Character

Internal

• General

• Number

 

Use

• Date

 

• Conversion

 

Oracle

 

Multiple-Row Functions

 

Functions an manipulate groups of rows to give one result per group of rows. These functions are also known as group functions (covered in lesson 5 titled “Reporting Aggregated Data Using the Group Functions”).

Note: For more information and a complete list of available functions and their syntax, see the topic,

Functions in Oracle Database SQL Language Reference 11g, Release 1 (11.1).

Oracle Database 11g: SQL Fundamentals I 3 - 5

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]