File: syntax.html

package info (click to toggle)
mpsql 2.1-2
  • links: PTS
  • area: non-free
  • in suites: potato
  • size: 3,528 kB
  • ctags: 4,886
  • sloc: ansic: 35,184; makefile: 3,761; sh: 44
file content (566 lines) | stat: -rw-r--r-- 10,085 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>SQL Syntax</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet version 1.19"><LINK
REL="HOME"
TITLE="PostgreSQL User's Guide"
HREF="user.html"><LINK
REL="PREVIOUS"
TITLE="Destroying a Database"
HREF="manage453.html"><LINK
REL="NEXT"
TITLE="Data Types"
HREF="datatype.html"></HEAD
><BODY
BGCOLOR="#FFFFFF"
TEXT="#000000"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PostgreSQL User's Guide</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="manage453.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="datatype.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="SYNTAX"
>Chapter 4. SQL Syntax</A
></H1
><H1
CLASS="SECT1"
><A
NAME="AEN460"
>Key Words</A
></H1
><P
><SPAN
CLASS="ACRONYM"
>SQL92</SPAN
> defines <I
CLASS="FIRSTTERM"
>key words</I
> 
for the language
which have specific meaning. Some key words are
<I
CLASS="FIRSTTERM"
>reserved</I
>, which indicates that they are
restricted to appear in only certain contexts. Other key words are
<I
CLASS="FIRSTTERM"
>not restricted</I
>, which indicates that in certain 
contexts they
have a specific meaning but are not otherwise constrained.&#13;</P
><P
><SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
> implements an extended subset of the
<SPAN
CLASS="ACRONYM"
>SQL92</SPAN
> and <SPAN
CLASS="ACRONYM"
>SQL3</SPAN
> languages. Some language
elements are not as restricted in this implementation as is
called for in the language standards, in part due
to the extensibility features of <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
>. &#13;</P
><P
>Information on <SPAN
CLASS="ACRONYM"
>SQL92</SPAN
> and <SPAN
CLASS="ACRONYM"
>SQL3</SPAN
> key words
is derived from <A
HREF="biblio.html#DATE97"
><I
>A Guide to the <I
>SQL</I
> Standard</I
></A
>.&#13;</P
><H2
CLASS="SECT2"
><A
NAME="AEN476"
>Reserved Key Words</A
></H2
><P
><SPAN
CLASS="ACRONYM"
>SQL92</SPAN
> and <SPAN
CLASS="ACRONYM"
>SQL3</SPAN
> have 
<I
CLASS="FIRSTTERM"
>reserved key words</I
> which are not allowed 
as identifiers and not allowed in any usage other than as fundamental
tokens in <SPAN
CLASS="ACRONYM"
>SQL</SPAN
> statements.
<SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
> has additional key words
which have similar restrictions. In particular, these key words
are not allowed as column or table names, though in some cases
they are allowed to be column labels (i.e. in AS clauses).

<BLOCKQUOTE
CLASS="TIP"
><P
><B
>Tip: </B
>Any string can be specified as an identifier if surrounded by
double quotes (&#8220;like this!&#8221;). Some care is required since
such an identifier will be case sensitive
and will retain embedded whitespace other special characters.</P
></BLOCKQUOTE
>&#13;</P
><P
>The following are <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
>
reserved words which are neither <SPAN
CLASS="ACRONYM"
>SQL92</SPAN
>
nor <SPAN
CLASS="ACRONYM"
>SQL3</SPAN
> reserved words. These are allowed
to be present as column labels, but not as identifiers:

<PRE
CLASS="PROGRAMLISTING"
>ABORT ANALYZE 
BINARY 
CLUSTER CONSTRAINT COPY
DO 
EXPLAIN EXTEND
LISTEN LOAD LOCK 
MOVE 
NEW NONE NOTIFY 
RESET 
SETOF SHOW
UNLISTEN UNTIL 
VACUUM VERBOSE</PRE
>

The following are <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
>
reserved words which are also <SPAN
CLASS="ACRONYM"
>SQL92</SPAN
> 
or <SPAN
CLASS="ACRONYM"
>SQL3</SPAN
> reserved words, and which
are allowed to be present as column labels, but not as identifiers:

<PRE
CLASS="PROGRAMLISTING"
>CROSS CURRENT 
FALSE FOREIGN 
GROUP 
ORDER 
POSITION PRECISION 
TABLE TRANSACTION TRUE</PRE
>

The following are <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
>
reserved words which are also <SPAN
CLASS="ACRONYM"
>SQL92</SPAN
> 
or <SPAN
CLASS="ACRONYM"
>SQL3</SPAN
> reserved words:

<PRE
CLASS="PROGRAMLISTING"
>ADD ALL ALTER AND ANY AS ASC
BEGIN BETWEEN BOTH BY
CASCADE CAST CHAR CHARACTER CHECK CLOSE COLLATE COLUMN COMMIT 
CONSTRAINT CREATE CURRENT_DATE CURRENT_TIME 
CURRENT_TIMESTAMP CURRENT_USER CURSOR
DECIMAL DECLARE DEFAULT DELETE DESC DISTINCT DROP
END EXECUTE EXISTS EXTRACT
FETCH FLOAT FOR FROM FULL
GRANT 
HAVING
IN INNER INSERT INTERVAL INTO IS
JOIN 
LEADING LEFT LIKE LOCAL
NAMES NATIONAL NATURAL NCHAR NO NOT NULL NUMERIC
ON OR OUTER
PARTIAL PRIMARY PRIVILEGES PROCEDURE PUBLIC
REFERENCES REVOKE RIGHT ROLLBACK
SELECT SET SUBSTRING
TO TRAILING TRIM 
UNION UNIQUE UPDATE USER USING
VALUES VARCHAR VARYING VIEW
WHERE WITH WORK </PRE
>

The following are <SPAN
CLASS="ACRONYM"
>SQL92</SPAN
> reserved key words which
are not <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
> reserved key words, but which
if used as function names are always translated into the function
<TT
CLASS="FUNCTION"
>length</TT
>:

<PRE
CLASS="PROGRAMLISTING"
>CHAR_LENGTH CHARACTER_LENGTH</PRE
>

The following are <SPAN
CLASS="ACRONYM"
>SQL92</SPAN
> or <SPAN
CLASS="ACRONYM"
>SQL3</SPAN
> 
reserved key words which
are not <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
> reserved key words, but
if used as type names which are always translated into an alternate, native type:

<PRE
CLASS="PROGRAMLISTING"
>BOOLEAN DOUBLE FLOAT INT INTEGER INTERVAL REAL SMALLINT</PRE
>&#13;</P
><P
>The following are either <SPAN
CLASS="ACRONYM"
>SQL92</SPAN
>
or <SPAN
CLASS="ACRONYM"
>SQL3</SPAN
> reserved key words
which are not key words in <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
>.
These have no proscribed usage in <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
>
at the time of writing (v6.4) but may become reserved key words in the
future:

<BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>Some of these key words represent functions in <SPAN
CLASS="ACRONYM"
>SQL92</SPAN
>.
These functions are defined in <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
>,
but the parser does not consider the names to be key words and they are allowed
in other contexts.</P
></BLOCKQUOTE
>

<PRE
CLASS="PROGRAMLISTING"
>ALLOCATE ARE ASSERTION AT AUTHORIZATION AVG 
BIT BIT_LENGTH
CASCADED CASE CATALOG COALESCE COLLATION
CONNECT CONNECTION CONSTRAINTS CONTINUE CONVERT CORRESPONDING COUNT
DATE DEALLOCATE DEC DESCRIBE DESCRIPTOR DIAGNOSTICS DISCONNECT DOMAIN 
ELSE END-EXEC ESCAPE EXCEPT EXCEPTION EXEC EXTERNAL 
FIRST FOUND
GET GLOBAL GO GOTO 
IDENTITY IMMEDIATE INDICATOR INITIALLY INPUT INTERSECT ISOLATION 
LAST LEVEL LOWER 
MAX MIN MODULE 
NULLIF
OCTET_LENGTH OPEN OUTPUT OVERLAPS 
PREPARE PRESERVE 
RESTRICT ROWS
SCHEMA SECTION SESSION SESSION_USER SIZE SOME 
SQL SQLCODE SQLERROR SQLSTATE SUM SYSTEM_USER
TEMPORARY THEN TRANSLATE TRANSLATION 
UNKNOWN UPPER USAGE
VALUE 
WHEN WHENEVER WRITE</PRE
>&#13;</P
><H2
CLASS="SECT2"
><A
NAME="AEN518"
>Non-reserved Keywords</A
></H2
><P
><SPAN
CLASS="ACRONYM"
>SQL92</SPAN
> and <SPAN
CLASS="ACRONYM"
>SQL3</SPAN
> have 
<I
CLASS="FIRSTTERM"
>non-reserved keywords</I
> which have
a proscribed meaning in the language but which are also allowed
as identifiers.
<SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
> has additional keywords
which allow similar unrestricted usage.
In particular, these keywords
are allowed as column or table names.&#13;</P
><P
>The following are <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
>
non-reserved key words which are neither <SPAN
CLASS="ACRONYM"
>SQL92</SPAN
>
nor <SPAN
CLASS="ACRONYM"
>SQL3</SPAN
> non-reserved key words:

<PRE
CLASS="PROGRAMLISTING"
>AFTER AGGREGATE 
BACKWARD BEFORE 
CACHE CREATEDB CREATEUSER CYCLE
DATABASE DELIMITERS 
EACH ENCODING 
FORWARD FUNCTION 
HANDLER
INCREMENT INDEX INHERITS INSENSITIVE INSTEAD ISNULL
LANCOMPILER LOCATION 
MAXVALUE MINVALUE
NOCREATEDB NOCREATEUSER NOTHING NOTNULL 
OIDS OPERATOR 
PASSWORD PROCEDURAL
RECIPE RENAME  RETURNS ROW RULE
SEQUENCE SERIAL START STATEMENT STDIN STDOUT 
TRUSTED 
VALID VERSION</PRE
>&#13;</P
><P
>The following are <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
>
non-reserved key words which are <SPAN
CLASS="ACRONYM"
>SQL92</SPAN
>
or <SPAN
CLASS="ACRONYM"
>SQL3</SPAN
> reserved key words:

<PRE
CLASS="PROGRAMLISTING"
>ABSOLUTE ACTION
DAY
HOUR
INSENSITIVE 
KEY 
LANGUAGE 
MATCH MINUTE MONTH
NEXT 
OF ONLY OPTION 
PRIOR PRIVILEGES 
READ RELATIVE 
SCROLL SECOND
TIME TIMESTAMP TIMEZONE_HOUR TIMEZONE_MINUTE TRIGGER 
YEAR
ZONE</PRE
>&#13;</P
><P
>The following are <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
>
non-reserved key words which are also either <SPAN
CLASS="ACRONYM"
>SQL92</SPAN
>
or <SPAN
CLASS="ACRONYM"
>SQL3</SPAN
> non-reserved key words:

<PRE
CLASS="PROGRAMLISTING"
>TYPE</PRE
>&#13;</P
><P
>The following are either <SPAN
CLASS="ACRONYM"
>SQL92</SPAN
>
or <SPAN
CLASS="ACRONYM"
>SQL3</SPAN
> non-reserved key words which are not
key words of any kind in <SPAN
CLASS="PRODUCTNAME"
>Postgres</SPAN
>:

<PRE
CLASS="PROGRAMLISTING"
>ADA
C CATALOG_NAME CHARACTER_SET_CATALOG CHARACTER_SET_NAME 
CHARACTER_SET_SCHEMA CLASS_ORIGIN COBOL COLLATION_CATALOG
COLLATION_NAME COLLATION_SCHEMA COLUMN_NAME
COMMAND_FUNCTION COMMITTED CONDITION_NUMBER
CONNECTION_NAME CONSTRAINT_CATALOG CONSTRAINT_NAME
CONSTRAINT_SCHEMA CURSOR_NAME
DATA DATE_TIME_INTERVAL_CODE DATE_TIME_INTERVAL_PRECISION
DYNAMIC_FUNCTION
FORTRAN
LENGTH
MESSAGE_LENGTH MESSAGE_OCTET_LENGTH MORE MUMPS
NAME NULLABLE NUMBER
PAD PASCAL PLI
REPEATABLE RETURNED_LENGTH RETURNED_OCTET_LENGTH
RETURNED_SQLSTATE ROW_COUNT
SCALE SCHEMA_NAME SERIALIZABLE SERVER_NAME SPACE
SUBCLASS_ORIGIN
TABLE_NAME
UNCOMMITTED UNNAMED</PRE
>&#13;</P
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="manage453.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="user.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="datatype.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Destroying a Database</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Data Types</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>