クエリ: SELECT ステートメント

ビューにクエリを実行するには、SELECT ステートメントを使用します。以下の各節では、 SELECT ステートメントの各句の使用方法を説明します。

すべての VQL ステートメントの構文は、コマンド HELP を実行すると確認できます (「 ヘルプコマンド 」を参照)。

SELECT ステートメントの構文
<query> ::=
  [ WITH <common table expressions> ]
  { <select> | <complex select> }
  [ <order by> ]
  [ <result offset clause> ]
  [ <fetch first clause> ]
  [ CONTEXT ( <context information> [ , <context information> ]* ) ]
  [ TRACE ]

<select> ::=
  SELECT [ DISTINCT ] <select fields>
  FROM <view> [ , <view> ]*
  [ WHERE <condition> | <subselect condition> ]
  [ GROUP BY <group by field> [ , <group by field> ]*
    [ HAVING <condition> ]
  ]

<complex select> ::=
    <complex select> [ { UNION [ ALL ] | MINUS | INTERSECT }
                         <complex select> ]+
  | SELECT [ DISTINCT ] <select fields>
      FROM ( <complex select> [ <order by> ] )
  | ( <complex select> )
  | <select>

<select fields> ::=
  <select field> [ [ AS ] <alias:identifier> ]
  [, <select field> [ [ AS ] <alias:identifier> ] ]*

<select field> ::=
    *
  | <value>
  | <value> = <value>

<common table expressions> ::=
  <common table expression> [ , <common table expression> ]*

<common table expression> ::=
  <query name:view identifier>
  [ ( <field name:identifier> [ , <field name:identifier> ]* ) ]
  AS ( { <select> | <complex select> }
  [ <order by> ] )

<result offset clause> ::=
  OFFSET <offset row count:number> [ ROW | ROWS ]

<fetch first clause> ::=
    FETCH { FIRST | NEXT } [ <fetch first quantity:number> ] { ROW | ROWS } ONLY
  | LIMIT [ <number> ]

<view> ::=
    <simple view>
  | <join view>
  | ( <select> )

<simple view> ::=
    <view:identifier> [ [ AS ] <alias:identifier> ]
  | [ <database name:identifier> .]<procedure:identifier>
    ( [ <procedureParameter> [, <procedureParameter> ]* ] )
    [ [ AS ] <alias:identifier> ]
  | <flatten view>

<join view> ::=
    <inner view1:view> [ <method type> ] [ <order type> ] [ <join type> ]
    JOIN <inner view2:view> ON <condition>
  | <inner view1:view> NESTED PARALLEL [ <order type> ] [ <join type> ]
    JOIN [ <parallel number:integer> ] <inner view2:view> ON <condition>
  | <inner view1:view> [ <method type> ] [ <order type> ]
    NATURAL [ <join type> ] JOIN <inner view2:view>
  | <inner view1:view> NESTED PARALLEL [ <order type> ]
    NATURAL [ <join type> ] JOIN [ <parallel number:integer> ]
    <inner view2:view>
  | <inner view1:view> [ <method type> ] [ <order type> ] [ <join type> ]
    JOIN <inner view2:view> USING ( <field> [ , <field> ]* )
  | <inner view1:view> NESTED PARALLEL [ <order type> ] [ <join type> ]
    JOIN [ <parallel number:integer> ] <inner view2:view>
    USING ( <field> [ , <field> ]* )
  | <inner view1:view> CROSS JOIN <inner view2:view>

<inner view> ::=
    <simple view>
  | ( <view> )

<join type> ::=
    LEFT [ OUTER ]
  | RIGHT [ OUTER ]
  | FULL [ OUTER ]
  | INNER

<method type> ::=
    HASH
  | NESTED
  | MERGE

<order type> ::=
    ORDERED
  | REVERSEORDER

<join condition> ::=
    <simple join condition> [ AND <simple join condition> ]*
  | ( <join condition> )

<simple join condition> ::=
    <field1:field name> <binary operator> <field2:field name>
  | <field2:field name> <binary operator> <field1:field name>


<subselect condition> ::=
    <condition>
  | <subselect condition> AND <subselect condition>
  | <subselect condition> OR <subselect condition>
  | NOT <subselect condition>
  | <value> <binary operator> [ ALL | ANY ]
    ( <select> | <complex select> [ <order by> ] )
  | <value> [ NOT ] IN ( <select> | <complex select> [ <order by> ] )
  | [ NOT ] EXISTS ( <select> | <complex select> [ <order by> ] )

<column names> ::=
  <column name> [, <column name> ]*

<column name> ::=
    <identifier>
  | <literal>

<group by field> ::=
    <field name>
  | <expression> }

<order by> ::= (「 ORDER BY 句の構文 (SELECT ステートメント) 」を参照)

<flatten view> ::= (「 FLATTEN 操作の構文 」を参照)

<view identifier> ::= (「 VQL ステートメントの基本エレメント 」を参照)

<condition> ::= (「 関数の記述ルール 」を参照)

<unary operator> ::= (「 VQL ステートメントの基本エレメント 」を参照)

<binary operator> ::= (「 VQL ステートメントの基本エレメント 」を参照)

<field name> ::= (「 関数の記述ルール 」を参照)

<context information> ::= (「 CONTEXT 句の構文 」を参照)

<value> ::= (「 関数の記述ルール 」を参照)