Die Syntax von SQL (vereinfacht)
- Direkte SQL-Anweisung
Direkte SQL-Anweisung
.------------------------. .-.
---.--->| Direkte Datenanweisung |---.--->( ; )--->
| '------------------------' ^ '-'
| .------------------------. |
'--->| Schemaanweisung |---'
'------------------------'
Direkte Datenanweisungen (Direkte SQL-Anweisung)
- Direkte Datenanweisung
Direkte Datenanweisung
.-------------------.
---.--->| Abfrageausdruck |---.--->
| '-------------------' |
| .-------------------. |
'--->| Einfuegeanweisung |---'
'-------------------'
Abfrageausdrücke (Direkte Datenanweisung)
- Abfrageausdruck
(7.13, 7.12)
<direct select statement: multiple rows> ::= <cursor specification> [22.2, 1408a2, 1383b]
<cursor specification> ::= <query expression> [14.3, 1124a2, 1099b]
<query expression> ::= [ <with clause> ] <query expression body> [ <order by clause> ] [7.17, 512a2, 487b]
<query expression body> ::= <query term> | <query expression body> UNION [ ALL | DISTINCT ] [ <corresponding spec> ] <query term> | <query expression body> EXCEPT [ ALL | DISTINCT ] [ <corresponding spec> ] <query term> [7.17, 512a2, 487b]
<query term> ::= <query primary> | <query term> INTERSECT [ ALL | DISTINCT ] [ <corresponding spec> ] <query primary> [7.17, 512a2, 487b]
<query primary> ::= <simple table> | <left paren> <query expression body> [ <order by clause> ] [ <result offset clause> ] [ <fetch first clause> ] <right paren> [7.17, 512a2, 487b]
<simple table> ::= <query specification> | <table value constructor> | <explicit table> [7.17, 512a2, 487b]
<query specification> ::= SELECT [ <set quantifier> ] <select list> <table expression> [7.16, 501a2, 476b]
Abfrageausdruck.------. .--------------. .------------------.
--->( SELECT )--->| Auswahlliste |--->| Tabellenausdruck |--->
'------' '--------------' '------------------'- Auswahlliste
(7.12)
<select list> ::= <asterisk>| <select sublist> [ { <comma> <select sublist> }... ] [7.16, 501a2, 476b]
<select sublist> ::= <derived column> | <qualified asterisk> [7.16, 501a2, 476b]
<qualified asterisk> ::= <asterisked identifier chain> <period> <asterisk> | <all fields reference> [7.16, 501a2, 476b]
<asterisked identifier chain> ::= <asterisked identifier> [ { <period> <asterisked identifier> }... ] [7.16, 501a2, 476b]
<asterisked identifier> ::= <identifier> [7.16, 501a2, 476b]
<derived column> ::= <value expression> [ <as clause> ] [7.16, 501a2, 476b]
<as clause> ::= [ AS ] <column name> [7.16, 501a2, 476b]
<all fields reference> ::= <value expression primary> <period> <asterisk> [ AS <left paren> <all fields column name list> <right paren> ] [7.16, 501a2, 476b]
<all fields column name list> ::= <column name list> [7.16, 501a2, 476b]
Auswahlliste.------------.
---.---.--->| Bezeichner |---.---.--->
| ^ '------------' | |
| | .-. | |
| '--------( , )--------' |
| '-' |
| .-. |
'----------->( * )------------'
'-'- Tabellenausdruck
(7.4)
<table expression> ::=<from clause> [ <where clause> ] [ <group by clause> ] [ <having clause> ] [ <window clause> ] [7.4, 415a2, 390b]
<from clause> ::= FROM <table reference list> <table reference list> ::= <table reference> [ { <comma> <table reference> }... ] [7.5, 416a2, 391b]
<table reference> ::= <table factor> | <joined table> [7.6, 419a2, 394b]
<table factor> ::= <table primary> [7.6, 419a2, 394b]
<table primary> ::= <table or query name> [7.6, 419a2, 394b]
<where clause> ::= WHERE <search condition> [7.12, 474a2, 449b]
<search condition> ::= <boolean value expression> [8.12, 593a2, 568b]
<boolean value expression> ::= <boolean term> | <boolean value expression> OR <boolean term> [6.39, 390a2, 365b]
<boolean term> ::= <boolean factor> | <boolean term> AND <boolean factor> [6.39, 390a2, 365b]
<boolean factor> ::= [ NOT ] <boolean test> [6.39, 390a2, 365b]
<boolean test> ::= <boolean primary> [ IS [ NOT ] <truth value> ] [6.39, 390a2, 365b]
<truth value> ::= TRUE | FALSE | UNKNOWN [6.39, 390a2, 365b]
<boolean primary> ::= <predicate> | <boolean predicand> [6.39, 390a2, 365b]
<boolean predicand> ::= <parenthesized boolean value expression> | <nonparenthesized value expression primary> [6.39, 390a2, 365b]
<parenthesized boolean value expression> ::= <left paren> <boolean value expression> <right paren> [6.39, 390a2, 365b]
<predicate> ::= <comparison predicate> | <between predicate> | <in predicate> | <like predicate> | <similar predicate> | <regex like predicate> | <null predicate> | <quantified comparison predicate> | <exists predicate> | <unique predicate> | <normalized predicate> | <match predicate> | <overlaps predicate> | <distinct predicate> | <member predicate> | <submultiset predicate> | <set predicate> | <type predicate> | <period predicate> | <JSON predicate> | <JSON exists predicate> [8.1, 538a2, 513b]
<comparison predicate> ::= <row value predicand> <comparison predicate part 2> [8.2, 540a2, 515b]
<comparison predicate part 2> ::= <comp op> <row value predicand> [8.2, 540a2, 515b]
<comp op> ::= <equals operator> | <not equals operator> | <less than operator> | <greater than operator> | <less than or equals operator> | <greater than or equals operator> [8.2, 540a2, 515b]Tabellenausdruck
.----. .------------.
--->( FROM )--->| Bezeichner |--->
'----' '------------'
Einfügeanweisungen (Direkte Datenanweisung)
- Einfuegeanweisung (vereinfacht)
Einfuegeanweisung
.------. .-----. .------------. .-. .------------. .-. .------. .-. .--------. .-.
--->( INSERT )--->( INTO )--->| Bezeichner |---.--->( ( )--->| Bezeichner |--->( ) )---.--->( VALUES )---.--->( ( )--->| Skalar |--->( ) )---.--->
'------' '-----' '------------' | '-' '------------' '-' ^ '------' ^ '-' '--------' '-' |
| | | .-. |
'---------------------------------------' '----------------( , )--------------'
'-'- Mehrzeilige Einfuegeanweisung (vereinfacht) *
Einfuegeanweisung
.------. .-----. .------------. .-. .------------. .-. .------. .-. .--------. .-. .-.
--->( INSERT )--->( INTO )--->| Bezeichner |---.--->( ( )--->| Bezeichner |--->( ) )---.--->( VALUES )---.--->( ( )---.--->| Skalar |---.--->( ) )---.--->( ; )--->
'------' '-----' '------------' | '-' '------------' '-' ^ '------' ^ '-' ^ '--------' | '-' | '-'
Tabellenname | Spaltenname | | | | |
| | | | .-. | |
'---------------------------------------' | '-------( , )-----' |
| '-' |
| |
| .-. |
'--------------------( , )------------------'
'-'- Einfügeanweisung (<insert statement>) (vereinfacht)
.------. .----. .------------. .----------------------------.
--->( INSERT )--->( INTO )--->| Bezeichner |--->| Einfuegespalten und Quelle |--->
'------' '----' '------------' '----------------------------'
Tabellenname- Einfuegespalten und Quelle (<insert columns and source>) (vereinfacht)
.--------------------------------------------------.
| |
| .-. .----------------------. .-. V .-------------------------------------------------.
--->'--->( ( )--->| Einfuegespaltenliste |--->( ) )--->'--->| kontextuell typisierter Tabellenwertkonstruktor |--->
'-' '----------------------' '-' '-------------------------------------------------'
Schemaanweisungen (Direkte SQL-Anweisung)
- Schemaanweisung
Schemaanweisung
.--------------------------------.
---.--->| Schemadefinitionsanweisung |---.--->
| '--------------------------------' |
| .--------------------------------. |
'--->| Schemamanipulationsanweisung |---'
'--------------------------------'
Schemadefinitionsanweisungen (Schemaanweisung)
- Schemadefinitionsanweisung
Schemadefinitionsanweisung
.----------------------.
---.--->| Tabellendefinition |---.--->
| '----------------------' |
| .----------------------. |
'--->| Ansichtsdefinition |---'
| '----------------------' |
| .----------------------. |
'--->| Schemadefinition |---'
'----------------------'
Tabellendefinitionen (Schemadefinitionsanweisung)
- Tabellendefinitionsanweisung
Tabellendefinitionsanweisung
.------. .-----. .------------. .-. .----------------------. .-.
--->( CREATE )--->( TABLE )--->| Bezeichner |--->( ( )---.--->| Spaltenspezifikation |--->.---( ) )--->
'------' '-----' '------------' '-' ^ '----------------------' | '-'
Tabellenname | .-. |
'-------------( , )--------------'
'-'- Spaltenspezifikation
Spaltenspezifikation
.------------. .----------.
--->| Bezeichner |--->| Datentyp |--->
'------------' '----------'
Spaltenname
Ansichtsdefinitionen (Schemadefinitionsanweisung)
- Ansichtsdefinition
(11.31)
Ansichtsdefinition.------. .----. .------------. .--. .-----------------.
--->( CREATE )--->( VIEW )--->| Bezeichner |--->( AS )--->| Abfrageausdruck |--->
'------' '----' '------------' '--' '-----------------'
Ansichtsname
Schemadefinitionen (Schemadefinitionsanweisung)
- Schemadefinition
Schemadefinition
.------. .------. .------------.
--->( CREATE )--->( SCHEMA )--->| Bezeichner |--->
'------' '------' '------------'
Schemamanipulationsanweisungen (Schemaanweisung)
- Schemamanipulationsanweisung
Schemamanipulationsanweisung
.-----------------------.
---.--->| Drop-Schema-Anweisung |---.--->
| '-----------------------' |
| .-----------------------. |
'--->| Drop-Table-Anweisung |---'
| '-----------------------' |
| .-----------------------. |
'--->| Drop-View-Anweisung |---'
'-----------------------'
DROP-SCHEMA-Anweisung (Schemamanipulationsanweisung)
- DROP-SCHEMA-Anweisung
DROP-SCHEMA-Anweisung
.----. .------. .------------.
--->( DROP )--->( SCHEMA )--->| Bezeichner |--->
'----' '------' '------------'
Schemaname
DROP-TABLE-Anweisung (Schemamanipulationsanweisung)
- DROP-TABLE-Anweisung
DROP-TABLE-Anweisung
.----. .-----. .------------.
--->( DROP )--->( TABLE )--->| Bezeichner |--->
'----' '-----' '------------'
Tabellenname
DROP-VIEW-Anweisung (Schemamanipulationsanweisung)
- DROP-VIEW-Anweisung
DROP-VIEW-Anweisung
.----. .----. .------------.
--->( DROP )--->( VIEW )--->| Bezeichner |--->
'----' '----' '------------'
Ansichtname