3 SQL式

この章では、値、演算子およびファンクションを式の中で組み合せて使用する場合の構文について説明します。

この章の内容は次のとおりです。

SQL式のタイプの構文

式は、1つ以上の値、演算子、およびある値に評価されるSQLファンクションの組合せです。一般に、式のデータ型は、そのコンポーネントのデータ型になります。

式にはいくつかの書式があります。この項では、各書式の式に対する構文を示します。副次句の構文については、「副次句」を参照してください。

関連項目:

SQL式の詳細は、『Oracle Database SQL言語リファレンス』を参照してください。

計算済メジャー式

{    av_meas_expression
   | av_simple_expression
   | single_row_function_expression
   | case_expression
   | compound_expression
   | datetime_expression
   | interval_expression
}

CASE式

CASE { simple_case_expression
     | searched_case_expression
     }
     [ else_clause ]
     END

列の式

列の式は、単純式、複合式またはファンクション式であったり、あるいは対象となる表の列、制約および決定的ファンクションのみを含む式のリストの場合もあります。

複合式

{ (expr)
| { + | - | PRIOR } expr
| expr { * | / | + | - | || } expr
| expr COLLATE collation_name
}

Note: The double vertical bars are part of the syntax
      (indicating concatenation) rather than BNF notation.

CURSOR式

CURSOR (subquery)

日時式

expr AT
   { LOCAL
   | TIME ZONE { ' [ + | - ] hh:mi'
               | DBTIMEZONE
               | 'time_zone_name'
               | expr
               }
   }

ファンクション式

組込みSQLファンクションまたはユーザー定義ファンクションを式として使用できます。

期間式

( expr1 - expr2 )
   { DAY [ (leading_field_precision) ] TO
     SECOND [ (fractional_second_precision) ]
   | YEAR [ (leading_field_precision) ] TO
     MONTH
   }

JSONオブジェクト・アクセス式

table_alias.JSON_column [.JSON_object_key [ array_step ]... ]...

モデル式

{ measure_column [ { condition | expr } [, { condition | expr } ]... ]
| aggregate_function 
     { [ { condition | expr } [, { condition | expr } ]... ]
     | [ single_column_for_loop [, single_column_for_loop ]... ]
     | [ multi_column_for_loop ]
     }
| analytic_function
}

Note: The outside square brackets shown in boldface type are part of
      the syntax. In this case, they do not represent optionality.

オブジェクト・アクセス式

{ table_alias.column.
| object_table_alias.
| (expr).
}
{ attribute [.attribute ]...
  [.method ([ argument [, argument ]... ]) ]
| method ([ argument [, argument ]... ])
}

プレースホルダ式

:host_variable
   [ [ INDICATOR ]
     :indicator_variable
   ]

スカラー副問合せ式

スカラー副問合せ式は、1つの行から1つの列値のみを戻す副問合せです。

単純式

{ [ query_name.
  | [schema.] { table. | view. | materialized view. }
  | t_alias.
  ] { column | ROWID }
| ROWNUM
| string
| number
| sequence. { CURRVAL | NEXTVAL }
| NULL
}

型コンストラクタ式

[ NEW ] [ schema. ]type_name
   ([ expr [, expr ]... ])