sqlite-referenzgxy.ch/efinf/db/db-sqlite-ref-handout.pdf1 sqlite schl usselw orter der sql-standard...
TRANSCRIPT
SQLite-Referenz
Inhaltsverzeichnis
1 SQLite Schlusselworter 3
2 Datentypen 3
3 Aggregatfunktionen 3
4 Datum und Zeit 4
5 SQLite-Statements 4
alter-table-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
analyze-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
attach-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
begin-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
column-constraint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
column-def . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
commit-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
comment-syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
commit-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
common-table-expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
compound-operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
compound-select-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
conflict-clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
create-index-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
create-table-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
create-trigger-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
create-view-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
create-virtual-table-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
ct-table-name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
delete-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
delete-stmt-limited . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
detach-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
drop-index-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
drop-table-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
drop-trigger-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1
drop-view-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
expr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
factored-select-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
foreign-key-clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
indexed-column . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
insert-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
join-clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
join-constraint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
join-operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
literal-value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
numeric-literal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
ordering-term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
pragma-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
qualified-table-name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
raise-function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
reindex-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
release-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
result-column . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
rollback-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
savepoint-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
select-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
select-core . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
signed-number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
simple-select-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
sql-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
sql-stmt-list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
table-constraint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
table-or-subquery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
type-name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
update-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
update-stmt-limited . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
vacuum-stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
with-clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2
1 SQLite Schlusselworter
Der SQL-Standard definiert eine grosse Zahl von Schlusselwortern, die nicht als Namenvon Tabellen, Indizes, Kolonnen, Datenbanken, oder anderen benutzerdefinierten Objek-ten verwendet werden durfen.
Die Liste dieser Schlusselworter ist so lang (124), dass nur wenige Leute alle auswen-dig kennen. Am sichersten ist es, uberhaupt kein englisches Wort als Bezeichner fur einbenutzerdefiniertes Objekt zu verwenden.
Wenn man dennoch ein Schlusselwort als Bezeichner verwenden mochte, muss man es inAnfuhrungszeichen setzen. Hier die beiden wichtigsten Varianten, dies zu tun:
• Ein Schlusselwort in einfachen Anfuhrungszeichen (’...’) ist eine Zeichenkette.
• Ein Schlusselwort in doppelten Anfuhrungszeichen ("...") ist ein Variablenname.
2 Datentypen
• NULL der NULL-Wert
• INTEGER eine ganze Zahl mit Vorzeichen
• REAL Fliesskommazahl
• TEXT Zeichenkette (auch fur Datum und Zeit)
• BLOB (Binary Large Object) exakte Kopie des Inputs
3 Aggregatfunktionen
• avg()
• count()
• group concat()
• max()
• min()
• sum()
• total() (ahnlich wie sum())
3
4 Datum und Zeit
Datum- und Zeitangaben werden am einfachsten als TEXT gespeichert. Es sind auch Dar-stellungen als REAL moglich, die jedoch Umrechnungen erfordern. Hier einige Darstellun-gen, die von SQLite erkannt werden:
• ’YYYY-MM-DD’
• ’YYYY-MM-DD HH:MM’
• ’YYYY-MM-DD HH:MM:SS’
• ’YYYY-MM-DD HH:MM:SS.sss’
• ’HH:MM’
• ’HH:MM:SS’
• ’HH:MM:SS.sss’
5 SQLite-Statements
alter-table-stmt
analyze-stmt
attach-stmt
4
begin-stmt
column-constraint
column-def
commit-stmt
comment-syntax
5
commit-stmt
common-table-expression
compound-operator
compound-select-stmt
6
conflict-clause
create-index-stmt
create-table-stmt
7
create-trigger-stmt
create-view-stmt
8
create-virtual-table-stmt
cte-table-name
delete-stmt
delete-stmt-limited
detach-stmt
9
drop-index-stmt
drop-table-stmt
drop-trigger-stmt
drop-view-stmt
10
expr
11
factored-select-stmt
foreign-key-clause
indexed-column
12
insert-stmt
join-clause
join-constraint
join-operator
13
literal-value
numeric-literal
ordering-term
pragma-stmt
qualified-table-name
14
raise-function
reindex-stmt
release-stmt
result-column
rollback-stmt
savepoint-stmt
15
select-stmt
16
select-core
signed-number
simple-select-stmt
17
sql-stmt
sql-stmt-list
18
table-constraint
table-or-subquery
type-name
19
update-stmt
update-limited
vacuum-stmt
with-clause
20