Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
47
Добавлен:
16.04.2013
Размер:
774.99 Кб
Скачать

3

SQL Expressions

This chapter presents the syntax for combining values, operators, and functions into expressions.

This chapter includes the following section:

Syntax for SQL Expression Types

Syntax for SQL Expression Types

An expression is a combination of one or more values, operators, and SQL functions that evaluate to a value. An expression generally assumes the datatype of its components.

Expressions have several forms. Table 3–1 shows the syntax for each form of expression. Refer to Chapter 5, "Subclauses" for the syntax of the subclauses found in the following table.

See Also: Expressions in Oracle Database SQL Reference for detailed information about SQL expressions

Table 3–1 Syntax for SQL Expression Types

SQL Expression Type

Syntax

 

 

 

CASE expression

CASE {

simple_case_expression

 

|

searched_case_expression

 

}

 

 

[

else_clause ]

 

END

SQL Expressions 3-1

Syntax for SQL Expression Types

Table 3–1 (Cont.) Syntax for SQL Expression Types

SQL Expression Type

Syntax

 

 

 

 

Compound expression

{ (expr)

 

 

| { + | - | PRIOR } expr

 

 

| expr { * | / | + | - | || } expr

 

 

}

 

 

Note: The double vertical bars are part of the syntax

 

(indicating concatenation) rather than BNF

 

notation.

 

CURSOR expression

CURSOR (subquery)

 

DATETIME expression

datetime_value_expr AT

 

 

{ LOCAL

 

 

| TIME ZONE { ' [ + | - ] hh:mm'

 

 

| DBTIMEZONE

 

 

| 'time_zone_name'

 

 

| expr

 

 

}

 

 

}

 

Function expression

any built-in SQL function or user-defined function can be

 

used as an expression

 

INTERVAL expression

interval_value_expr

 

 

{ DAY [ (leading_field_precision) ] TO

 

SECOND [ (fractional_second_precision) ]

 

| YEAR [ (leading_field_precision) ] TO

 

MONTH

 

 

}

 

Model expression

{ measure_column | aggregate_funtion }

 

 

[ { condition | expr }

 

 

[ , { condition | expr } ]...

 

 

]

 

 

Note: The outside square brackets are part of the syntax.

 

In this case, they do not represent optionality.

Object access expression

{ table_alias.column.

 

 

| object_table_alias.

 

 

| (expr).

 

 

}

 

 

{ attribute [.attribute ]...

 

 

[.method ([ argument [, argument ]...

]) ]

 

| method ([ argument [, argument ]... ])

 

 

}

 

Scalar subquery expression

a subquery that returns exactly one column value from one

 

row can be used as an expression

 

3-2 Oracle Database SQL Quick Reference

Syntax for SQL Expression Types

Table 3–1 (Cont.) Syntax for SQL Expression Types

SQL Expression Type

Syntax

 

 

Simple expression

{ [ query_name.

 

| [schema.]

 

{ table. | view. | materialized view. }

 

] { column | ROWID }

 

| ROWNUM

 

| text

 

| number

 

| sequence. { CURRVAL | NEXTVAL }

 

| NULL

 

}

Type constructor expression

[ NEW ] [ schema. ]type_name

 

([ expr [, expr ]... ])

Variable expression

:host_variable

 

[ [ INDICATOR ]

 

:indicator_variable

 

]

 

 

SQL Expressions 3-3

Syntax for SQL Expression Types

3-4 Oracle Database SQL Quick Reference

Соседние файлы в папке Oracle 10g