Skip to content
walter-weinmann edited this page Nov 30, 2017 · 32 revisions

sql_list:

    sql_list ::= ( sql ';' extra? )+
referenced by:

extra:

    extra    ::= NAME ';'
referenced by:

NAME:

    NAME     ::= [A-Za-z] [A-Za-z0-9_@\$~]*
referenced by:

sql:

    sql      ::= procedure_call
               | schema
               | cursor_def
               | manipulative_statement
               | 'WHENEVER' ( 'NOT' 'FOUND' | 'SQLERROR' ) when_action
referenced by:

procedure_call:

    procedure_call
             ::= 'DECLARE'? 'BEGIN' ( ( function_ref ';' )+ | sql_list ) 'END'
               | 'CALL' function_ref
referenced by:

schema:

    schema   ::= 'CREATE' 'SCHEMA' 'AUTHORIZATION' NAME schema_element*
referenced by:

schema_element:

    schema_element
             ::= create_role_def
               | create_table_def
               | create_index_def
               | create_user_def
               | view_def
referenced by:

create_role_def:

    create_role_def
             ::= 'CREATE' 'ROLE' NAME
referenced by:

create_table_def:

    create_table_def
             ::= 'CREATE' tbl_scope? tbl_type? 'TABLE' table '(' ( base_table_element ( ',' base_table_element )* )? ')'
referenced by:

create_user_def:

    create_user_def
             ::= 'CREATE' 'USER' NAME identified user_opt*
referenced by:

drop_table_def:

    drop_table_def
             ::= 'DROP' NAME? 'TABLE' ( 'IF' 'EXISTS' )? table ( ',' table )* ( 'RESTRICT' | 'CASCADE' )?
referenced by:

drop_role_def:

    drop_role_def
             ::= 'DROP' 'ROLE' NAME
referenced by:

drop_index_def:

    drop_index_def
             ::= 'DROP' 'INDEX' index_name? 'FROM' table
referenced by:

index_name:

    index_name
             ::= NAME ( '.' NAME )?
referenced by:

create_index_def:

    create_index_def
             ::= 'CREATE' ( 'BITMAP' | 'KEYLIST' | 'HASHMAP' | 'UNIQUE' )? 'INDEX' index_name? 'ON' table ( '(' NAME JSON? ( ',' NAME JSON? )* ')' )? ( 'NORM_WITH' STRING )? ( 'FILTER_WITH' STRING )?
referenced by:

JSON:

    JSON     ::= '|' [:{\[#] [^|]+ '|'
referenced by:

STRING:

    STRING   ::= 'fun' [A-Za-z0-9,_]* '.'* '->' '.'* 'end.'
               | 'fun\s' ['A-Za-z0-9_]+ ':' ['A-Za-z0-9_]+ '/' [0-9]+ '.'
               | "'" [^\']* "''**"
referenced by:

tbl_scope:

    tbl_scope
             ::= 'LOCAL'
               | 'CLUSTER'
               | 'SCHEMA'
referenced by:

tbl_type:

    tbl_type ::= 'SET'
               | 'ORDERED_SET'
               | 'BAG'
               | NAME
referenced by:

alter_user_def:

    alter_user_def
             ::= 'ALTER' 'USER' NAME ( ( ',' NAME )* proxy_clause | spec_item+ | NAME NAME )
referenced by:

drop_user_def:

    drop_user_def
             ::= 'DROP' 'USER' NAME 'CASCADE'?
referenced by:

proxy_clause:

    proxy_clause
             ::= ( 'GRANT' | 'REVOKE' ) 'CONNECT' 'THROUGH' ( 'ENTERPRISE' 'USERS' | db_user_proxy )
referenced by:

db_user_proxy:

    db_user_proxy
             ::= proxy_with
               | proxy_with? 'AUTHENTICATION' 'REQUIRED'
referenced by:

proxy_with:

    proxy_with
             ::= 'WITH' ( 'NO' 'ROLES' | 'ROLE' ( 'ALL' 'EXCEPT' )? role_list )
referenced by:

spec_item:

    spec_item
             ::= identified
               | user_opt
               | user_role
referenced by:

user_role:

    user_role
             ::= 'DEFAULT' 'ROLE' ( 'ALL' ( 'EXCEPT' role_list )? | NONE | role_list )
referenced by:

role_list:

    role_list
             ::= NAME ( ',' NAME )*
referenced by:

identified:

    identified
             ::= IDENTIFIED ( ( 'BY' | EXTERNALLY 'AS' ) NAME | 'GLOBALLY' ( 'AS' NAME )? )
referenced by:

user_opt:

    user_opt ::= ( ( 'DEFAULT' | 'TEMPORARY' ) 'TABLESPACE' | 'PROFILE' ) NAME
               | quota+
referenced by:

quota:

    quota    ::= 'QUOTA' ( 'UNLIMITED' | INTNUM NAME? ) 'ON' NAME
referenced by:

INTNUM:

    INTNUM   ::= [0-9]+
referenced by:

base_table_element:

    base_table_element
             ::= column_def
               | table_constraint_def
referenced by:

column_def:

    column_def
             ::= column data_type column_def_opt*
referenced by:

column_def_opt:

    column_def_opt
             ::= 'NOT' 'NULL' ( 'UNIQUE' | 'PRIMARY' 'KEY' )?
               | 'DEFAULT' ( function_ref | literal | NAME | 'NULL' | 'USER' )
               | 'CHECK' '(' search_condition ')'
               | 'REFERENCES' table ( '(' column_commalist ')' )?
referenced by:

table_constraint_def:

    table_constraint_def
             ::= ( ( 'UNIQUE' | 'PRIMARY' 'KEY' ) '(' column_commalist | 'CHECK' '(' search_condition ) ')'
               | 'FOREIGN' 'KEY' '(' column_commalist ')' 'REFERENCES' table ( '(' column_commalist ')' )?
referenced by:

column_commalist:

    column_commalist
             ::= column ( ',' column )*
referenced by:

view_def:

    view_def ::= 'CREATE' 'VIEW' table ( '(' column_commalist ')' )?
               | 'AS' query_spec ( 'WITH' 'CHECK' 'OPTION' )?
referenced by:

grant_def:

    grant_def
             ::= 'GRANT' ( ( 'All' 'PRIVILEGES' | object_privilege ( ',' object_privilege )* ) on_obj_clause 'TO' ( grantee_identified_by | grantee_revokee ( ',' grantee_revokee )* ) ( 'WITH' ( 'GRANT' | 'HIERARCHY' ) 'OPTION' )? | ( 'All' 'PRIVILEGES' | system_privilege ( ',' system_privilege )* ) 'TO' ( grantee_identified_by | grantee_revokee ( ',' grantee_revokee )* ) ( 'WITH' ( 'ADMIN' | 'DELEGATE' ) 'OPTION' )? )
referenced by:

revoke_def:

    revoke_def
             ::= 'REVOKE' ( ( 'All' 'PRIVILEGES' | object_privilege ( ',' object_privilege )* ) on_obj_clause 'FROM' grantee_revokee ( ',' grantee_revokee )* ( 'CASCADE' 'CONSTRAINTS' | 'FORCE' )? | ( 'All' 'PRIVILEGES' | system_privilege ( ',' system_privilege )* ) 'FROM' grantee_revokee ( ',' grantee_revokee )* )
referenced by:

object_privilege:

    object_privilege
             ::= 'ALL'
               | 'ALTER'
               | 'DELETE'
               | 'EXECUTE'
               | 'INDEX'
               | 'INSERT'
               | 'REFERENCES'
               | 'SELECT'
               | 'UPDATE'
referenced by:

on_obj_clause:

    on_obj_clause
             ::= 'ON' ( table | 'DIRECTORY' NAME )
referenced by:

system_privilege:

    system_privilege
             ::= 'ADMIN'
               | 'ALL'
               | ( 'ALTER' | 'CREATE' | 'DROP' ) 'ANY' ( 'INDEX' | 'MATERIALIZED'? 'VIEW' | 'TABLE' )
               | 'CREATE' ( 'MATERIALIZED'? 'VIEW' | 'TABLE' )
               | ( 'DELETE' | 'INSERT' | 'SELECT' | 'UPDATE' ) 'ANY' 'TABLE'
               | NAME
referenced by:

grantee_revokee:

    grantee_revokee
             ::= NAME
               | 'PUBLIC'
referenced by:

grantee_identified_by:

    grantee_identified_by
             ::= NAME 'IDENTIFIED' 'BY' STRING
referenced by:

cursor_def:

    cursor_def
             ::= 'DECLARE' cursor 'CURSOR' 'FOR' query_exp order_by_clause?
referenced by:

order_by_clause:

    order_by_clause
             ::= 'ORDER' 'BY' ordering_spec ( ',' ordering_spec )*
referenced by:

ordering_spec:

    ordering_spec
             ::= scalar_exp ( 'ASC' | 'DESC' )?
referenced by:

manipulative_statement:

    manipulative_statement
             ::= close_statement
               | commit_statement
               | delete_statement_positioned
               | delete_statement_searched
               | fetch_statement
               | insert_statement
               | open_statement
               | rollback_statement
               | select_statement
               | update_statement_positioned
               | update_statement_searched
               | create_table_def
               | create_role_def
               | create_index_def
               | create_user_def
               | drop_role_def
               | drop_table_def
               | drop_index_def
               | alter_user_def
               | drop_user_def
               | view_def
               | truncate_table
               | grant_def
               | revoke_def
referenced by:

table_name:

    table_name
             ::= NAME ( '.' NAME ( '.' NAME )? )?
referenced by:

truncate_table:

    truncate_table
             ::= 'TRUNCATE' 'TABLE' table_name ( ( 'PRESERVE' | 'PURGE' ) 'MATERIALIZED' 'VIEW' 'LOG' )? ( ( 'DROP' | 'REUSE' ) 'STORAGE' )?
referenced by:

close_statement:

    close_statement
             ::= 'CLOSE' cursor
referenced by:

commit_statement:

    commit_statement
             ::= 'COMMIT' 'WORK'?
referenced by:

delete_statement_positioned:

    delete_statement_positioned
             ::= 'DELETE' 'FROM' table 'WHERE' 'CURRENT' 'OF' cursor returning?
referenced by:

delete_statement_searched:

    delete_statement_searched
             ::= 'DELETE' 'FROM' table where_clause? returning?
referenced by:

fetch_statement:

    fetch_statement
             ::= 'FETCH' cursor 'INTO' target_commalist
referenced by:

insert_statement:

    insert_statement
             ::= 'INSERT' 'INTO' table ( ( '(' column_commalist ')' )? ( 'VALUES' '(' scalar_opt_as_exp ( ',' scalar_opt_as_exp )* ')' | query_spec ) returning? )?
referenced by:

open_statement:

    open_statement
             ::= 'OPEN' cursor
referenced by:

rollback_statement:

    rollback_statement
             ::= 'ROLLBACK' 'WORK'?
referenced by:

select_statement:

    select_statement
             ::= query_exp
referenced by:

update_statement_positioned:

    update_statement_positioned
             ::= 'UPDATE' table 'SET' assignment_commalist 'WHERE' 'CURRENT' 'OF' cursor returning?
referenced by:

assignment_commalist:

    assignment_commalist
             ::= assignment ( ',' assignment )*
referenced by:

assignment:

    assignment
             ::= column '=' scalar_opt_as_exp
referenced by:

update_statement_searched:

    update_statement_searched
             ::= 'UPDATE' table 'SET' assignment_commalist where_clause? returning?
referenced by:

target_commalist:

    target_commalist
             ::= target ( ',' target )*
referenced by:

target:

    target   ::= NAME
               | parameter_ref
referenced by:

query_exp:

    query_exp
             ::= query_term ( ( 'UNION' 'ALL'? | 'INTERSECT' | 'MINUS' ) query_term )*
referenced by:

returning:

    returning
             ::= ( 'RETURNING' | 'RETURN' ) selection 'INTO' selection
referenced by:

query_term:

    query_term
             ::= query_spec
               | '(' query_exp ')'
referenced by:

query_spec:

    query_spec
             ::= 'SELECT' HINT? ( 'ALL' | 'DISTINCT' )? selection ( 'INTO' target_commalist ( 'IN' NAME )? )? table_exp
referenced by:

HINT:

    HINT     ::= '/*' [^\*/]* '*/'
referenced by:

selection:

    selection
             ::= select_field_commalist
referenced by:

select_field:

    select_field
             ::= case_when_exp ( 'AS'? NAME )?
               | scalar_opt_as_exp
               | '*'
referenced by:

select_field_commalist:

    select_field_commalist
             ::= select_field ( ',' select_field )*
referenced by:

case_when_exp:

    case_when_exp
             ::= '(' case_when_exp ')'
               | 'CASE' scalar_opt_as_exp? case_when_then_list ( 'ELSE' scalar_opt_as_exp )? 'END'
referenced by:

case_when_then_list:

    case_when_then_list
             ::= case_when_then+
referenced by:

case_when_then:

    case_when_then
             ::= 'WHEN' search_condition 'THEN' scalar_opt_as_exp
referenced by:

from_column:

    from_column
             ::= table_ref
               | '(' join_clause ')'
               | join_clause
referenced by:

table_exp:

    table_exp
             ::= 'FROM' from_column+ where_clause? hierarchical_query_clause? ( 'GROUP' 'BY' column_ref_commalist )? ( 'HAVING' search_condition )? order_by_clause?
referenced by:

join:

    join     ::= inner_cross_join
               | outer_join
referenced by:

join_clause:

    join_clause
             ::= table_ref join+
referenced by:

inner_cross_join:

    inner_cross_join
             ::= 'INNER'? 'JOIN' join_ref join_on_or_using_clause
               | ( 'CROSS' | 'NATURAL' 'INNER'? ) 'JOIN' join_ref
referenced by:

join_on_or_using_clause:

    join_on_or_using_clause
             ::= 'ON' search_condition
               | 'USING' '(' select_field_commalist ')'
referenced by:

outer_join:

    outer_join
             ::= query_partition_clause? 'NATURAL'? outer_join_type 'JOIN' join_ref query_partition_clause? join_on_or_using_clause?
referenced by:

query_partition_clause:

    query_partition_clause
             ::= 'PARTITION' 'BY' ( '(' scalar_exp_commalist ')' | scalar_exp_commalist )
referenced by:

outer_join_type:

    outer_join_type
             ::= ( 'FULL' | 'LEFT' | 'RIGHT' ) 'OUTER'?
referenced by:

table_ref:

    table_ref
             ::= table
               | query_term NAME?
referenced by:

join_ref:

    join_ref ::= table
               | query_term NAME?
referenced by:

hierarchical_query_clause:

    hierarchical_query_clause
             ::= ( 'START' 'WITH' search_condition 'CONNECT' 'BY' 'NOCYCLE'? | 'CONNECT' 'BY' 'NOCYCLE'? search_condition 'START' 'WITH' ) search_condition
referenced by:

where_clause:

    where_clause
             ::= 'WHERE' search_condition
referenced by:

column_ref_commalist:

    column_ref_commalist
             ::= ( column_ref | function_ref ) ( ',' ( column_ref | function_ref ) )*
referenced by:

search_condition:

    search_condition
             ::= ( search_condition ( 'AND' | 'OR' ) | 'NOT' ) search_condition
               | '(' search_condition ')'
               | predicate
referenced by:

predicate:

    predicate
             ::= comparison_predicate
               | between_predicate
               | like_predicate
               | test_for_null
               | in_predicate
               | all_or_any_predicate
               | existence_test
referenced by:

comparison_predicate:

    comparison_predicate
             ::= scalar_opt_as_exp
               | ( scalar_exp ( '=' | COMPARISON ) 'PRIOR' | 'PRIOR' scalar_exp ( '=' | COMPARISON ) ) scalar_exp
referenced by:

COMPARISON:

    COMPARISON
             ::= '!='
               | '^='
               | '<>'
               | '<'
               | '>'
               | '<='
               | '>='
referenced by:

between_predicate:

    between_predicate
             ::= scalar_exp 'NOT'? 'BETWEEN' scalar_exp 'AND' scalar_exp
referenced by:

like_predicate:

    like_predicate
             ::= scalar_exp 'NOT'? 'LIKE' scalar_exp ( 'ESCAPE' atom )?
referenced by:

test_for_null:

    test_for_null
             ::= scalar_exp 'IS' 'NOT'? 'NULL'
referenced by:

in_predicate:

    in_predicate
             ::= scalar_exp 'NOT'? 'IN' ( '(' ( subquery | scalar_exp_commalist ) ')' | scalar_exp )
referenced by:

all_or_any_predicate:

    all_or_any_predicate
             ::= scalar_exp ( '=' | COMPARISON ) ( 'ANY' | 'ALL' | 'SOME' ) subquery
referenced by:

existence_test:

    existence_test
             ::= 'EXISTS' subquery
referenced by:

subquery:

    subquery ::= query_exp
referenced by:

scalar_opt_as_exp:

    scalar_opt_as_exp
             ::= scalar_exp ( ( '=' | COMPARISON ) scalar_exp | AS? NAME )?
referenced by:

scalar_exp:

    scalar_exp
             ::= scalar_sub_exp ( '||' scalar_sub_exp )*
referenced by:

scalar_sub_exp:

    scalar_sub_exp
             ::= ( scalar_sub_exp ( '+' | '-' | '*' | '/' | 'div' ) | '+' | '-' ) scalar_sub_exp
               | 'NULL'
               | atom
               | subquery
               | column_ref
               | function_ref
               | '(' scalar_sub_exp ')'
referenced by:

scalar_exp_commalist:

    scalar_exp_commalist
             ::= scalar_opt_as_exp ( ',' scalar_opt_as_exp )*
referenced by:

atom:

    atom     ::= parameter_ref
               | literal
               | 'USER'
referenced by:

parameter_ref:

    parameter_ref
             ::= parameter ( 'INDICATOR'? parameter )?
referenced by:

function_ref:

    function_ref
             ::= NAME ( '.' NAME ( '.' NAME )? )? '(' fun_args ')'
               | 'FUNS' ( '(' ( fun_args | '*' | 'DISTINCT' column_ref | 'ALL' scalar_exp ) ')' )?
referenced by:

fun_args:

    fun_args ::= fun_arg ( ',' fun_arg )*
referenced by:

fun_arg:

    fun_arg  ::= '(' fun_arg ')'
               | function_ref
               | column_ref
               | fun_arg ( ( '+' | '-' | '*' | '/' | 'div' | '||' | '=' | COMPARISON ) fun_arg | 'AS' NAME )
               | ( '+' | '-' ) fun_arg
               | 'NULL'
               | atom
               | subquery
referenced by:

literal:

    literal  ::= STRING
               | INTNUM
               | APPROXNUM
referenced by:

APPROXNUM:

    APPROXNUM
             ::= ( '.' [0-9] | [0-9]+ '.'? ) [0-9]* ( [eE] [+#x2D]? [0-9]+ )? [fFdD]?
referenced by:

table:

    table    ::= ( NAME ( '.' NAME )? | parameter ) NAME?
               | STRING
referenced by:

column_ref:

    column_ref
             ::= ( NAME ( '.' NAME ( '.' NAME )? )? )? JSON
               | NAME ( ( '.' NAME ( '.' NAME )? )? ( '(' '+' ')' )? | '.' ( NAME '.' )? '*' )
referenced by:

data_type:

    data_type
             ::= STRING
               | NAME ( '(' sgn_num ( ',' sgn_num )? ')' )?
referenced by:

sgn_num:

    sgn_num  ::= '-'? INTNUM
referenced by:

column:

    column   ::= NAME
               | STRING
referenced by:

cursor:

    cursor   ::= NAME
referenced by:

parameter:

    parameter
             ::= PARAMETER
referenced by:

PARAMETER:

    PARAMETER
             ::= ':' [A-Za-z0-9_\.]+
referenced by:

when_action:

    when_action
             ::= 'GOTO' NAME
               | 'CONTINUE'
referenced by:

  ... generated by Railroad Diagram Generator


Clone this wiki locally