Update section on SQL syntax. (Still a lot to be done though.) Add
authorPeter Eisentraut
Sat, 6 Jan 2001 11:58:56 +0000 (11:58 +0000)
committerPeter Eisentraut
Sat, 6 Jan 2001 11:58:56 +0000 (11:58 +0000)
appendix with comprehensive list of key words.

doc/src/sgml/datetime.sgml
doc/src/sgml/filelist.sgml
doc/src/sgml/keywords.sgml [new file with mode: 0644]
doc/src/sgml/syntax.sgml
doc/src/sgml/user.sgml

index 5244f353b80ecca7fdbf34042112dfddefac8485..5a035db4b46aa5666457474443313be00a03234a 100644 (file)
@@ -1,9 +1,9 @@
 
 
-label="UG1" id="datetime-appendix">
+
  Date/Time Support
 
  
index 8458ae7275f16a051870f370c7fad07d4a158b61..799f517144fd405c4aeea0f3dc1ff8519ddd3c39 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
 
 
@@ -35,6 +35,7 @@
 
 
 
+
 
 
 
diff --git a/doc/src/sgml/keywords.sgml b/doc/src/sgml/keywords.sgml
new file mode 100644 (file)
index 0000000..3ee3b93
--- /dev/null
@@ -0,0 +1,3163 @@
+
<acronym>SQL</acronym> Key Words
+
+   lists all tokens that are key words
+  in the SQL standard and in PostgreSQL
+  &version;.  Background information can be found in 
+  linkend="sql-syntax-identifiers">.
+
+  SQL distinguishes between reserved and
+  non-reserved key words.  Reserved key words
+  are the only real key words; they are never allowed as identifiers.
+  Non-reserved key words only have a special meaning in particular
+  contexts and can be used as identifiers in other contexts.  Most
+  non-reserved key words are actually the names of built-in tables
+  and functions specified by SQL and the concept of non-reserved key
+  words essentially only exists to declare that some predefined meaning
+  is attached to a word in some contexts.
+
+  In the PostgreSQL parser life is a bit
+  more complicated. There are several different classes of tokens
+  ranging from those that can never be used as an identifier to those
+  that have absolutely no special status in the parser as compared to
+  an ordinary identifier.  (The latter is usually the case for
+  functions specified by SQL.)  Most SQL reserved key words are not
+  completely reserved in PostgreSQL, but
+  can be used as column label (as in SELECT 55 AS
+  CHECK, even though CHECK is a reserved key
+  word).
+
+  In  in the column for
+  PostgreSQL we classify as
+  non-reserved those key words that are explicitly
+  known to the parser but are allowed in most or all contexts where an
+  identifier is expected.  Labeled reserved are those
+  tokens that are only allowed as AS column label names
+  (and perhaps in very few other contexts).  The token
+  AS is the only exception: it cannot even be used as a
+  column label.  As a general rule, if you get spurious parser errors
+  for commands that contain any of the listed key words as an
+  identifier you should try to quote the identifier to see if the
+  problem goes away.
+
+  It is important to understand before studying 
+  linkend="keywords-table"> that the fact that a key word is not
+  reserved in PostgreSQL does not mean that
+  the feature related to the word is not implemented.  Conversely, the
+  presence of a key word does not indicate the existence of a feature.
+
+
+
+
+
<acronym>SQL</acronym> Key Words
+
+  
+   
+    Key Word
+    PostgreSQL
+    SQL 99
+    SQL 92
+   
+  
+
+  
+   
+    ABORT
+    reserved
+    
+    
+   
+   
+    ABS
+    
+    non-reserved
+    
+   
+   
+    ABSOLUTE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    ACCESS
+    non-reserved
+    
+    
+   
+   
+    ACTION
+    non-reserved
+    reserved
+    reserved
+   
+   
+    ADA
+    
+    non-reserved
+    non-reserved
+   
+   
+    ADD
+    non-reserved
+    reserved
+    reserved
+   
+   
+    ADMIN
+    
+    reserved
+    
+   
+   
+    AFTER
+    non-reserved
+    reserved
+    
+   
+   
+    AGGREGATE
+    non-reserved
+    reserved
+    
+   
+   
+    ALIAS
+    
+    reserved
+    
+   
+   
+    ALL
+    reserved
+    reserved
+    reserved
+   
+   
+    ALLOCATE
+    
+    reserved
+    reserved
+   
+   
+    ALTER
+    non-reserved
+    reserved
+    reserved
+   
+   
+    ANALYSE
+    reserved
+    
+    
+   
+   
+    ANALYZE
+    reserved
+    
+    
+   
+   
+    AND
+    reserved
+    reserved
+    reserved
+   
+   
+    ANY
+    reserved
+    reserved
+    reserved
+   
+   
+    ARE
+    
+    reserved
+    reserved
+   
+   
+    ARRAY
+    
+    reserved
+    
+   
+   
+    AS
+    reserved
+    reserved
+    reserved
+   
+   
+    ASC
+    reserved
+    reserved
+    reserved
+   
+   
+    ASENSITIVE
+    
+    non-reserved
+    
+   
+   
+    ASSERTION
+    
+    reserved
+    reserved
+   
+   
+    ASSIGNMENT
+    
+    non-reserved
+    
+   
+   
+    ASYMMETRIC
+    
+    non-reserved
+    
+   
+   
+    AT
+    non-reserved
+    reserved
+    reserved
+   
+   
+    ATOMIC
+    
+    non-reserved
+    
+   
+   
+    AUTHORIZATION
+    
+    reserved
+    reserved
+   
+   
+    AVG
+    
+    non-reserved
+    reserved
+   
+   
+    BACKWARD
+    non-reserved
+    
+    
+   
+   
+    BEFORE
+    non-reserved
+    reserved
+    
+   
+   
+    BEGIN
+    non-reserved
+    reserved
+    reserved
+   
+   
+    BETWEEN
+    reserved
+    non-reserved
+    reserved
+   
+   
+    BINARY
+    reserved
+    reserved
+    
+   
+   
+    BIT
+    reserved
+    reserved
+    reserved
+   
+   
+    BITVAR
+    
+    non-reserved
+    
+   
+   
+    BIT_LENGTH
+    
+    non-reserved
+    reserved
+   
+   
+    BLOB
+    
+    reserved
+    
+   
+   
+    BOOLEAN
+    
+    reserved
+    
+   
+   
+    BOTH
+    reserved
+    reserved
+    reserved
+   
+   
+    BREADTH
+    
+    reserved
+    
+   
+   
+    BY
+    non-reserved
+    reserved
+    reserved
+   
+   
+    C
+    
+    non-reserved
+    non-reserved
+   
+   
+    CACHE
+    non-reserved
+    
+    
+   
+   
+    CALL
+    
+    reserved
+    
+   
+   
+    CALLED
+    
+    non-reserved
+    
+   
+   
+    CARDINALITY
+    
+    non-reserved
+    
+   
+   
+    CASCADE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    CASCADED
+    
+    reserved
+    reserved
+   
+   
+    CASE
+    reserved
+    reserved
+    reserved
+   
+   
+    CAST
+    reserved
+    reserved
+    reserved
+   
+   
+    CATALOG
+    
+    reserved
+    reserved
+   
+   
+    CATALOG_NAME
+    
+    non-reserved
+    non-reserved
+   
+   
+    CHAIN
+    non-reserved
+    non-reserved
+    
+   
+   
+    CHAR
+    reserved
+    reserved
+    reserved
+   
+   
+    CHARACTER
+    reserved
+    reserved
+    reserved
+   
+   
+    CHARACTERISTICS
+    non-reserved
+    
+    
+   
+   
+    CHARACTER_LENGTH
+    
+    non-reserved
+    reserved
+   
+   
+    CHARACTER_SET_CATALOG
+    
+    non-reserved
+    non-reserved
+   
+   
+    CHARACTER_SET_NAME
+    
+    non-reserved
+    non-reserved
+   
+   
+    CHARACTER_SET_SCHEMA
+    
+    non-reserved
+    non-reserved
+   
+   
+    CHAR_LENGTH
+    
+    non-reserved
+    reserved
+   
+   
+    CHECK
+    reserved
+    reserved
+    reserved
+   
+   
+    CHECKED
+    
+    non-reserved
+    
+   
+   
+    CHECKPOINT
+    non-reserved
+    
+    
+   
+   
+    CLASS
+    
+    reserved
+    
+   
+   
+    CLASS_ORIGIN
+    
+    non-reserved
+    non-reserved
+   
+   
+    CLOB
+    
+    reserved
+    
+   
+   
+    CLOSE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    CLUSTER
+    reserved
+    
+    
+   
+   
+    COALESCE
+    reserved
+    non-reserved
+    reserved
+   
+   
+    COBOL
+    
+    non-reserved
+    non-reserved
+   
+   
+    COLLATE
+    reserved
+    reserved
+    reserved
+   
+   
+    COLLATION
+    
+    reserved
+    reserved
+   
+   
+    COLLATION_CATALOG
+    
+    non-reserved
+    non-reserved
+   
+   
+    COLLATION_NAME
+    
+    non-reserved
+    non-reserved
+   
+   
+    COLLATION_SCHEMA
+    
+    non-reserved
+    non-reserved
+   
+   
+    COLUMN
+    reserved
+    reserved
+    reserved
+   
+   
+    COLUMN_NAME
+    
+    non-reserved
+    non-reserved
+   
+   
+    COMMAND_FUNCTION
+    
+    non-reserved
+    non-reserved
+   
+   
+    COMMAND_FUNCTION_CODE
+    
+    non-reserved
+    
+   
+   
+    COMMENT
+    non-reserved
+    
+    
+   
+   
+    COMMIT
+    non-reserved
+    reserved
+    reserved
+   
+   
+    COMMITTED
+    non-reserved
+    non-reserved
+    non-reserved
+   
+   
+    COMPLETION
+    
+    reserved
+    
+   
+   
+    CONDITION_NUMBER
+    
+    non-reserved
+    non-reserved
+   
+   
+    CONNECT
+    
+    reserved
+    reserved
+   
+   
+    CONNECTION
+    
+    reserved
+    reserved
+   
+   
+    CONNECTION_NAME
+    
+    non-reserved
+    non-reserved
+   
+   
+    CONSTRAINT
+    reserved
+    reserved
+    reserved
+   
+   
+    CONSTRAINTS
+    non-reserved
+    reserved
+    reserved
+   
+   
+    CONSTRAINT_CATALOG
+    
+    non-reserved
+    non-reserved
+   
+   
+    CONSTRAINT_NAME
+    
+    non-reserved
+    non-reserved
+   
+   
+    CONSTRAINT_SCHEMA
+    
+    non-reserved
+    non-reserved
+   
+   
+    CONSTRUCTOR
+    
+    reserved
+    
+   
+   
+    CONTAINS
+    
+    non-reserved
+    
+   
+   
+    CONTINUE
+    
+    reserved
+    reserved
+   
+   
+    CONVERT
+    
+    non-reserved
+    reserved
+   
+   
+    COPY
+    reserved
+    
+    
+   
+   
+    CORRESPONDING
+    
+    reserved
+    reserved
+   
+   
+    COUNT
+    
+    non-reserved
+    reserved
+   
+   
+    CREATE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    CREATEDB
+    non-reserved
+    
+    
+   
+   
+    CREATEUSER
+    non-reserved
+    
+    
+   
+   
+    CROSS
+    reserved
+    reserved
+    reserved
+   
+   
+    CUBE
+    
+    reserved
+    
+   
+   
+    CURRENT
+    
+    reserved
+    reserved
+   
+   
+    CURRENT_DATE
+    reserved
+    reserved
+    reserved
+   
+   
+    CURRENT_PATH
+    
+    reserved
+    
+   
+   
+    CURRENT_ROLE
+    
+    reserved
+    
+   
+   
+    CURRENT_TIME
+    reserved
+    reserved
+    reserved
+   
+   
+    CURRENT_TIMESTAMP
+    reserved
+    reserved
+    reserved
+   
+   
+    CURRENT_USER
+    reserved
+    reserved
+    reserved
+   
+   
+    CURSOR
+    non-reserved
+    reserved
+    reserved
+   
+   
+    CURSOR_NAME
+    
+    non-reserved
+    non-reserved
+   
+   
+    CYCLE
+    non-reserved
+    reserved
+    
+   
+   
+    DATA
+    
+    reserved
+    non-reserved
+   
+   
+    DATABASE
+    non-reserved
+    
+    
+   
+   
+    DATE
+    
+    reserved
+    reserved
+   
+   
+    DATETIME_INTERVAL_CODE
+    
+    non-reserved
+    non-reserved
+   
+   
+    DATETIME_INTERVAL_PRECISION
+    
+    non-reserved
+    non-reserved
+   
+   
+    DAY
+    non-reserved
+    reserved
+    reserved
+   
+   
+    DEALLOCATE
+    
+    reserved
+    reserved
+   
+   
+    DEC
+    reserved
+    reserved
+    reserved
+   
+   
+    DECIMAL
+    reserved
+    reserved
+    reserved
+   
+   
+    DECLARE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    DEFAULT
+    reserved
+    reserved
+    reserved
+   
+   
+    DEFERRABLE
+    reserved
+    reserved
+    reserved
+   
+   
+    DEFERRED
+    non-reserved
+    reserved
+    reserved
+   
+   
+    DEFINED
+    
+    non-reserved
+    
+   
+   
+    DEFINER
+    
+    non-reserved
+    
+   
+   
+    DELETE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    DELIMITERS
+    non-reserved
+    
+    
+   
+   
+    DEPTH
+    
+    reserved
+    
+   
+   
+    DEREF
+    
+    reserved
+    
+   
+   
+    DESC
+    reserved
+    reserved
+    reserved
+   
+   
+    DESCRIBE
+    
+    reserved
+    reserved
+   
+   
+    DESCRIPTOR
+    
+    reserved
+    reserved
+   
+   
+    DESTROY
+    
+    reserved
+    
+   
+   
+    DESTRUCTOR
+    
+    reserved
+    
+   
+   
+    DETERMINISTIC
+    
+    reserved
+    
+   
+   
+    DIAGNOSTICS
+    
+    reserved
+    reserved
+   
+   
+    DICTIONARY
+    
+    reserved
+    
+   
+   
+    DISCONNECT
+    
+    reserved
+    reserved
+   
+   
+    DISPATCH
+    
+    non-reserved
+    
+   
+   
+    DISTINCT
+    reserved
+    reserved
+    reserved
+   
+   
+    DO
+    reserved
+    
+    
+   
+   
+    DOMAIN
+    
+    reserved
+    reserved
+   
+   
+    DOUBLE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    DROP
+    non-reserved
+    reserved
+    reserved
+   
+   
+    DYNAMIC
+    
+    reserved
+    
+   
+   
+    DYNAMIC_FUNCTION
+    
+    non-reserved
+    non-reserved
+   
+   
+    DYNAMIC_FUNCTION_CODE
+    
+    non-reserved
+    
+   
+   
+    EACH
+    non-reserved
+    reserved
+    
+   
+   
+    ELSE
+    reserved
+    reserved
+    reserved
+   
+   
+    ENCODING
+    non-reserved
+    
+    
+   
+   
+    END
+    reserved
+    reserved
+    reserved
+   
+   
+    END-EXEC
+    
+    reserved
+    reserved
+   
+   
+    EQUALS
+    
+    reserved
+    
+   
+   
+    ESCAPE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    EVERY
+    
+    reserved
+    
+   
+   
+    EXCEPT
+    reserved
+    reserved
+    reserved
+   
+   
+    EXCEPTION
+    
+    reserved
+    reserved
+   
+   
+    EXCLUSIVE
+    non-reserved
+    
+    
+   
+   
+    EXEC
+    
+    reserved
+    reserved
+   
+   
+    EXECUTE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    EXISTING
+    
+    non-reserved
+    
+   
+   
+    EXISTS
+    reserved
+    non-reserved
+    reserved
+   
+   
+    EXPLAIN
+    reserved
+    
+    
+   
+   
+    EXTEND
+    reserved
+    
+    
+   
+   
+    EXTERNAL
+    
+    reserved
+    reserved
+   
+   
+    EXTRACT
+    reserved
+    non-reserved
+    reserved
+   
+   
+    FALSE
+    reserved
+    reserved
+    reserved
+   
+   
+    FETCH
+    non-reserved
+    reserved
+    reserved
+   
+   
+    FINAL
+    
+    non-reserved
+    
+   
+   
+    FIRST
+    
+    reserved
+    reserved
+   
+   
+    FLOAT
+    reserved
+    reserved
+    reserved
+   
+   
+    FOR
+    reserved
+    reserved
+    reserved
+   
+   
+    FORCE
+    non-reserved
+    
+    
+   
+   
+    FOREIGN
+    reserved
+    reserved
+    reserved
+   
+   
+    FORTRAN
+    
+    non-reserved
+    non-reserved
+   
+   
+    FORWARD
+    non-reserved
+    
+    
+   
+   
+    FOUND
+    
+    reserved
+    reserved
+   
+   
+    FREE
+    
+    reserved
+    
+   
+   
+    FROM
+    reserved
+    reserved
+    reserved
+   
+   
+    FULL
+    reserved
+    reserved
+    reserved
+   
+   
+    FUNCTION
+    non-reserved
+    reserved
+    
+   
+   
+    G
+    
+    non-reserved
+    
+   
+   
+    GENERAL
+    
+    reserved
+    
+   
+   
+    GENERATED
+    
+    non-reserved
+    
+   
+   
+    GET
+    
+    reserved
+    reserved
+   
+   
+    GLOBAL
+    reserved
+    reserved
+    reserved
+   
+   
+    GO
+    
+    reserved
+    reserved
+   
+   
+    GOTO
+    
+    reserved
+    reserved
+   
+   
+    GRANT
+    non-reserved
+    reserved
+    reserved
+   
+   
+    GRANTED
+    
+    non-reserved
+    
+   
+   
+    GROUP
+    reserved
+    reserved
+    reserved
+   
+   
+    GROUPING
+    
+    reserved
+    
+   
+   
+    HANDLER
+    non-reserved
+    
+    
+   
+   
+    HAVING
+    reserved
+    reserved
+    reserved
+   
+   
+    HIERARCHY
+    
+    non-reserved
+    
+   
+   
+    HOLD
+    
+    non-reserved
+    
+   
+   
+    HOST
+    
+    reserved
+    
+   
+   
+    HOUR
+    non-reserved
+    reserved
+    reserved
+   
+   
+    IDENTITY
+    
+    reserved
+    reserved
+   
+   
+    IGNORE
+    
+    reserved
+    
+   
+   
+    ILIKE
+    reserved
+    
+    
+   
+   
+    IMMEDIATE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    IMPLEMENTATION
+    
+    non-reserved
+    
+   
+   
+    IN
+    reserved
+    reserved
+    reserved
+   
+   
+    INCREMENT
+    non-reserved
+    
+    
+   
+   
+    INDEX
+    non-reserved
+    
+    
+   
+   
+    INDICATOR
+    
+    reserved
+    reserved
+   
+   
+    INFIX
+    
+    non-reserved
+    
+   
+   
+    INHERITS
+    non-reserved
+    
+    
+   
+   
+    INITIALIZE
+    
+    reserved
+    
+   
+   
+    INITIALLY
+    reserved
+    reserved
+    reserved
+   
+   
+    INNER
+    reserved
+    reserved
+    reserved
+   
+   
+    INOUT
+    reserved
+    reserved
+    
+   
+   
+    INPUT
+    
+    reserved
+    reserved
+   
+   
+    INSENSITIVE
+    non-reserved
+    non-reserved
+    reserved
+   
+   
+    INSERT
+    non-reserved
+    reserved
+    reserved
+   
+   
+    INSTANCE
+    
+    non-reserved
+    
+   
+   
+    INSTANTIABLE
+    
+    non-reserved
+    
+   
+   
+    INSTEAD
+    non-reserved
+    
+    
+   
+   
+    INT
+    
+    reserved
+    reserved
+   
+   
+    INTEGER
+    
+    reserved
+    reserved
+   
+   
+    INTERSECT
+    reserved
+    reserved
+    reserved
+   
+   
+    INTERVAL
+    non-reserved
+    reserved
+    reserved
+   
+   
+    INTO
+    reserved
+    reserved
+    reserved
+   
+   
+    INVOKER
+    
+    non-reserved
+    
+   
+   
+    IS
+    reserved
+    reserved
+    reserved
+   
+   
+    ISNULL
+    reserved
+    
+    
+   
+   
+    ISOLATION
+    non-reserved
+    reserved
+    reserved
+   
+   
+    ITERATE
+    
+    reserved
+    
+   
+   
+    JOIN
+    reserved
+    reserved
+    reserved
+   
+   
+    K
+    
+    non-reserved
+    
+   
+   
+    KEY
+    non-reserved
+    reserved
+    reserved
+   
+   
+    KEY_MEMBER
+    
+    non-reserved
+    
+   
+   
+    KEY_TYPE
+    
+    non-reserved
+    
+   
+   
+    LANCOMPILER
+    non-reserved
+    
+    
+   
+   
+    LANGUAGE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    LARGE
+    
+    reserved
+    
+   
+   
+    LAST
+    
+    reserved
+    reserved
+   
+   
+    LATERAL
+    
+    reserved
+    
+   
+   
+    LEADING
+    reserved
+    reserved
+    reserved
+   
+   
+    LEFT
+    reserved
+    reserved
+    reserved
+   
+   
+    LENGTH
+    
+    non-reserved
+    non-reserved
+   
+   
+    LESS
+    
+    reserved
+    
+   
+   
+    LEVEL
+    non-reserved
+    reserved
+    reserved
+   
+   
+    LIKE
+    reserved
+    reserved
+    reserved
+   
+   
+    LIMIT
+    reserved
+    reserved
+    
+   
+   
+    LISTEN
+    reserved
+    
+    
+   
+   
+    LOAD
+    reserved
+    
+    
+   
+   
+    LOCAL
+    reserved
+    reserved
+    reserved
+   
+   
+    LOCALTIME
+    
+    reserved
+    
+   
+   
+    LOCALTIMESTAMP
+    
+    reserved
+    
+   
+   
+    LOCATION
+    non-reserved
+    
+    
+   
+   
+    LOCATOR
+    
+    reserved
+    
+   
+   
+    LOCK
+    reserved
+    
+    
+   
+   
+    LOWER
+    
+    non-reserved
+    reserved
+   
+   
+    M
+    
+    non-reserved
+    
+   
+   
+    MAP
+    
+    reserved
+    
+   
+   
+    MATCH
+    non-reserved
+    reserved
+    reserved
+   
+   
+    MAX
+    
+    non-reserved
+    reserved
+   
+   
+    MAXVALUE
+    non-reserved
+    
+    
+   
+   
+    MESSAGE_LENGTH
+    
+    non-reserved
+    non-reserved
+   
+   
+    MESSAGE_OCTET_LENGTH
+    
+    non-reserved
+    non-reserved
+   
+   
+    MESSAGE_TEXT
+    
+    non-reserved
+    non-reserved
+   
+   
+    METHOD
+    
+    non-reserved
+    
+   
+   
+    MIN
+    
+    non-reserved
+    reserved
+   
+   
+    MINUTE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    MINVALUE
+    non-reserved
+    
+    
+   
+   
+    MOD
+    
+    non-reserved
+    
+   
+   
+    MODE
+    non-reserved
+    
+    
+   
+   
+    MODIFIES
+    
+    reserved
+    
+   
+   
+    MODIFY
+    
+    reserved
+    
+   
+   
+    MODULE
+    
+    reserved
+    reserved
+   
+   
+    MONTH
+    non-reserved
+    reserved
+    reserved
+   
+   
+    MORE
+    
+    non-reserved
+    non-reserved
+   
+   
+    MOVE
+    reserved
+    
+    
+   
+   
+    MUMPS
+    
+    non-reserved
+    non-reserved
+   
+   
+    NAME
+    
+    non-reserved
+    non-reserved
+   
+   
+    NAMES
+    non-reserved
+    reserved
+    reserved
+   
+   
+    NATIONAL
+    non-reserved
+    reserved
+    reserved
+   
+   
+    NATURAL
+    reserved
+    reserved
+    reserved
+   
+   
+    NCHAR
+    reserved
+    reserved
+    reserved
+   
+   
+    NCLOB
+    
+    reserved
+    
+   
+   
+    NEW
+    reserved
+    reserved
+    
+   
+   
+    NEXT
+    non-reserved
+    reserved
+    reserved
+   
+   
+    NO
+    non-reserved
+    reserved
+    reserved
+   
+   
+    NOCREATEDB
+    non-reserved
+    
+    
+   
+   
+    NOCREATEUSER
+    non-reserved
+    
+    
+   
+   
+    NONE
+    non-reserved
+    reserved
+    
+   
+   
+    NOT
+    reserved
+    reserved
+    reserved
+   
+   
+    NOTHING
+    non-reserved
+    
+    
+   
+   
+    NOTIFY
+    non-reserved
+    
+    
+   
+   
+    NOTNULL
+    reserved
+    
+    
+   
+   
+    NULL
+    reserved
+    reserved
+    reserved
+   
+   
+    NULLABLE
+    
+    non-reserved
+    non-reserved
+   
+   
+    NULLIF
+    reserved
+    non-reserved
+    reserved
+   
+   
+    NUMBER
+    
+    non-reserved
+    non-reserved
+   
+   
+    NUMERIC
+    reserved
+    reserved
+    reserved
+   
+   
+    OBJECT
+    
+    reserved
+    
+   
+   
+    OCTET_LENGTH
+    
+    non-reserved
+    reserved
+   
+   
+    OF
+    non-reserved
+    reserved
+    reserved
+   
+   
+    OFF
+    reserved
+    reserved
+    
+   
+   
+    OFFSET
+    reserved
+    
+    
+   
+   
+    OIDS
+    non-reserved
+    
+    
+   
+   
+    OLD
+    reserved
+    reserved
+    
+   
+   
+    ON
+    reserved
+    reserved
+    reserved
+   
+   
+    ONLY
+    reserved
+    reserved
+    reserved
+   
+   
+    OPEN
+    
+    reserved
+    reserved
+   
+   
+    OPERATION
+    
+    reserved
+    
+   
+   
+    OPERATOR
+    non-reserved
+    
+    
+   
+   
+    OPTION
+    non-reserved
+    reserved
+    reserved
+   
+   
+    OPTIONS
+    
+    non-reserved
+    
+   
+   
+    OR
+    reserved
+    reserved
+    reserved
+   
+   
+    ORDER
+    reserved
+    reserved
+    reserved
+   
+   
+    ORDINALITY
+    
+    reserved
+    
+   
+   
+    OUT
+    reserved
+    reserved
+    
+   
+   
+    OUTER
+    reserved
+    reserved
+    reserved
+   
+   
+    OUTPUT
+    
+    reserved
+    reserved
+   
+   
+    OVERLAPS
+    reserved
+    non-reserved
+    reserved
+   
+   
+    OVERLAY
+    
+    non-reserved
+    
+   
+   
+    OVERRIDING
+    
+    non-reserved
+    
+   
+   
+    OWNER
+    non-reserved
+    
+    
+   
+   
+    PAD
+    
+    reserved
+    reserved
+   
+   
+    PARAMETER
+    
+    reserved
+    
+   
+   
+    PARAMETERS
+    
+    reserved
+    
+   
+   
+    PARAMETER_MODE
+    
+    non-reserved
+    
+   
+   
+    PARAMETER_NAME
+    
+    non-reserved
+    
+   
+   
+    PARAMETER_ORDINAL_POSITION
+    
+    non-reserved
+    
+   
+   
+    PARAMETER_SPECIFIC_CATALOG
+    
+    non-reserved
+    
+   
+   
+    PARAMETER_SPECIFIC_NAME
+    
+    non-reserved
+    
+   
+   
+    PARAMETER_SPECIFIC_SCHEMA
+    
+    non-reserved
+    
+   
+   
+    PARTIAL
+    non-reserved
+    reserved
+    reserved
+   
+   
+    PASCAL
+    
+    non-reserved
+    non-reserved
+   
+   
+    PASSWORD
+    non-reserved
+    
+    
+   
+   
+    PATH
+    non-reserved
+    reserved
+    
+   
+   
+    PENDANT
+    non-reserved
+    
+    
+   
+   
+    PLI
+    
+    non-reserved
+    non-reserved
+   
+   
+    POSITION
+    reserved
+    non-reserved
+    reserved
+   
+   
+    POSTFIX
+    
+    reserved
+    
+   
+   
+    PRECISION
+    reserved
+    reserved
+    reserved
+   
+   
+    PREFIX
+    
+    reserved
+    
+   
+   
+    PREORDER
+    
+    reserved
+    
+   
+   
+    PREPARE
+    
+    reserved
+    reserved
+   
+   
+    PRESERVE
+    
+    reserved
+    reserved
+   
+   
+    PRIMARY
+    reserved
+    reserved
+    reserved
+   
+   
+    PRIOR
+    non-reserved
+    reserved
+    reserved
+   
+   
+    PRIVILEGES
+    non-reserved
+    reserved
+    reserved
+   
+   
+    PROCEDURAL
+    non-reserved
+    
+    
+   
+   
+    PROCEDURE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    PUBLIC
+    reserved
+    reserved
+    reserved
+   
+   
+    READ
+    non-reserved
+    reserved
+    reserved
+   
+   
+    READS
+    
+    reserved
+    
+   
+   
+    REAL
+    
+    reserved
+    reserved
+   
+   
+    RECURSIVE
+    
+    reserved
+    
+   
+   
+    REF
+    
+    reserved
+    
+   
+   
+    REFERENCES
+    reserved
+    reserved
+    reserved
+   
+   
+    REFERENCING
+    
+    reserved
+    
+   
+   
+    REINDEX
+    non-reserved
+    
+    
+   
+   
+    RELATIVE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    RENAME
+    non-reserved
+    
+    
+   
+   
+    REPEATABLE
+    
+    non-reserved
+    non-reserved
+   
+   
+    RESET
+    reserved
+    
+    
+   
+   
+    RESTRICT
+    non-reserved
+    reserved
+    reserved
+   
+   
+    RESULT
+    
+    reserved
+    
+   
+   
+    RETURN
+    
+    reserved
+    
+   
+   
+    RETURNED_LENGTH
+    
+    non-reserved
+    non-reserved
+   
+   
+    RETURNED_OCTET_LENGTH
+    
+    non-reserved
+    non-reserved
+   
+   
+    RETURNED_SQLSTATE
+    
+    non-reserved
+    non-reserved
+   
+   
+    RETURNS
+    non-reserved
+    reserved
+    
+   
+   
+    REVOKE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    RIGHT
+    reserved
+    reserved
+    reserved
+   
+   
+    ROLE
+    
+    reserved
+    
+   
+   
+    ROLLBACK
+    non-reserved
+    reserved
+    reserved
+   
+   
+    ROLLUP
+    
+    reserved
+    
+   
+   
+    ROUTINE
+    
+    reserved
+    
+   
+   
+    ROUTINE_CATALOG
+    
+    non-reserved
+    
+   
+   
+    ROUTINE_NAME
+    
+    non-reserved
+    
+   
+   
+    ROUTINE_SCHEMA
+    
+    non-reserved
+    
+   
+   
+    ROW
+    non-reserved
+    reserved
+    
+   
+   
+    ROWS
+    
+    reserved
+    reserved
+   
+   
+    ROW_COUNT
+    
+    non-reserved
+    non-reserved
+   
+   
+    RULE
+    non-reserved
+    
+    
+   
+   
+    SAVEPOINT
+    
+    reserved
+    
+   
+   
+    SCALE
+    
+    non-reserved
+    non-reserved
+   
+   
+    SCHEMA
+    non-reserved
+    reserved
+    reserved
+   
+   
+    SCHEMA_NAME
+    
+    non-reserved
+    non-reserved
+   
+   
+    SCOPE
+    
+    reserved
+    
+   
+   
+    SCROLL
+    non-reserved
+    reserved
+    reserved
+   
+   
+    SEARCH
+    
+    reserved
+    
+   
+   
+    SECOND
+    non-reserved
+    reserved
+    reserved
+   
+   
+    SECTION
+    
+    reserved
+    reserved
+   
+   
+    SECURITY
+    
+    non-reserved
+    
+   
+   
+    SELECT
+    reserved
+    reserved
+    reserved
+   
+   
+    SELF
+    
+    non-reserved
+    
+   
+   
+    SENSITIVE
+    
+    non-reserved
+    
+   
+   
+    SEQUENCE
+    non-reserved
+    reserved
+    
+   
+   
+    SERIAL
+    non-reserved
+    
+    
+   
+   
+    SERIALIZABLE
+    non-reserved
+    non-reserved
+    non-reserved
+   
+   
+    SERVER_NAME
+    
+    non-reserved
+    non-reserved
+   
+   
+    SESSION
+    non-reserved
+    reserved
+    reserved
+   
+   
+    SESSION_USER
+    reserved
+    reserved
+    reserved
+   
+   
+    SET
+    non-reserved
+    reserved
+    reserved
+   
+   
+    SETOF
+    reserved
+    
+    
+   
+   
+    SETS
+    
+    reserved
+    
+   
+   
+    SHARE
+    non-reserved
+    
+    
+   
+   
+    SHOW
+    reserved
+    
+    
+   
+   
+    SIMILAR
+    
+    non-reserved
+    
+   
+   
+    SIMPLE
+    
+    non-reserved
+    
+   
+   
+    SIZE
+    
+    reserved
+    reserved
+   
+   
+    SMALLINT
+    
+    reserved
+    reserved
+   
+   
+    SOME
+    reserved
+    reserved
+    reserved
+   
+   
+    SOURCE
+    
+    non-reserved
+    
+   
+   
+    SPACE
+    
+    reserved
+    reserved
+   
+   
+    SPECIFIC
+    
+    reserved
+    
+   
+   
+    SPECIFICTYPE
+    
+    reserved
+    
+   
+   
+    SPECIFIC_NAME
+    
+    non-reserved
+    
+   
+   
+    SQL
+    
+    reserved
+    reserved
+   
+   
+    SQLCODE
+    
+    
+    reserved
+   
+   
+    SQLERROR
+    
+    
+    reserved
+   
+   
+    SQLEXCEPTION
+    
+    reserved
+    
+   
+   
+    SQLSTATE
+    
+    reserved
+    reserved
+   
+   
+    SQLWARNING
+    
+    reserved
+    
+   
+   
+    START
+    non-reserved
+    reserved
+    
+   
+   
+    STATE
+    
+    reserved
+    
+   
+   
+    STATEMENT
+    non-reserved
+    reserved
+    
+   
+   
+    STATIC
+    
+    reserved
+    
+   
+   
+    STDIN
+    non-reserved
+    
+    
+   
+   
+    STDOUT
+    non-reserved
+    
+    
+   
+   
+    STRUCTURE
+    
+    reserved
+    
+   
+   
+    STYLE
+    
+    non-reserved
+    
+   
+   
+    SUBCLASS_ORIGIN
+    
+    non-reserved
+    non-reserved
+   
+   
+    SUBLIST
+    
+    non-reserved
+    
+   
+   
+    SUBSTRING
+    reserved
+    non-reserved
+    reserved
+   
+   
+    SUM
+    
+    non-reserved
+    reserved
+   
+   
+    SYMMETRIC
+    
+    non-reserved
+    
+   
+   
+    SYSID
+    non-reserved
+    
+    
+   
+   
+    SYSTEM
+    
+    non-reserved
+    
+   
+   
+    SYSTEM_USER
+    
+    reserved
+    reserved
+   
+   
+    TABLE
+    reserved
+    reserved
+    reserved
+   
+   
+    TABLE_NAME
+    
+    non-reserved
+    non-reserved
+   
+   
+    TEMP
+    non-reserved
+    
+    
+   
+   
+    TEMPLATE
+    non-reserved
+    
+    
+   
+   
+    TEMPORARY
+    non-reserved
+    reserved
+    reserved
+   
+   
+    TERMINATE
+    
+    reserved
+    
+   
+   
+    THAN
+    
+    reserved
+    
+   
+   
+    THEN
+    reserved
+    reserved
+    reserved
+   
+   
+    TIME
+    non-reserved
+    reserved
+    reserved
+   
+   
+    TIMESTAMP
+    non-reserved
+    reserved
+    reserved
+   
+   
+    TIMEZONE_HOUR
+    non-reserved
+    reserved
+    reserved
+   
+   
+    TIMEZONE_MINUTE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    TO
+    reserved
+    reserved
+    reserved
+   
+   
+    TOAST
+    non-reserved
+    
+    
+   
+   
+    TRAILING
+    reserved
+    reserved
+    reserved
+   
+   
+    TRANSACTION
+    reserved
+    reserved
+    reserved
+   
+   
+    TRANSACTIONS_COMMITTED
+    
+    non-reserved
+    
+   
+   
+    TRANSACTIONS_ROLLED_BACK
+    
+    non-reserved
+    
+   
+   
+    TRANSACTION_ACTIVE
+    
+    non-reserved
+    
+   
+   
+    TRANSFORM
+    
+    non-reserved
+    
+   
+   
+    TRANSFORMS
+    
+    non-reserved
+    
+   
+   
+    TRANSLATE
+    
+    non-reserved
+    reserved
+   
+   
+    TRANSLATION
+    
+    reserved
+    reserved
+   
+   
+    TREAT
+    
+    reserved
+    
+   
+   
+    TRIGGER
+    non-reserved
+    reserved
+    
+   
+   
+    TRIGGER_CATALOG
+    
+    non-reserved
+    
+   
+   
+    TRIGGER_NAME
+    
+    non-reserved
+    
+   
+   
+    TRIGGER_SCHEMA
+    
+    non-reserved
+    
+   
+   
+    TRIM
+    reserved
+    non-reserved
+    reserved
+   
+   
+    TRUE
+    reserved
+    reserved
+    reserved
+   
+   
+    TRUNCATE
+    non-reserved
+    
+    
+   
+   
+    TRUSTED
+    non-reserved
+    
+    
+   
+   
+    TYPE
+    non-reserved
+    non-reserved
+    non-reserved
+   
+   
+    UNCOMMITTED
+    
+    non-reserved
+    non-reserved
+   
+   
+    UNDER
+    
+    reserved
+    
+   
+   
+    UNION
+    reserved
+    reserved
+    reserved
+   
+   
+    UNIQUE
+    reserved
+    reserved
+    reserved
+   
+   
+    UNKNOWN
+    
+    reserved
+    reserved
+   
+   
+    UNLISTEN
+    non-reserved
+    
+    
+   
+   
+    UNNAMED
+    
+    non-reserved
+    non-reserved
+   
+   
+    UNNEST
+    
+    reserved
+    
+   
+   
+    UNTIL
+    non-reserved
+    
+    
+   
+   
+    UPDATE
+    non-reserved
+    reserved
+    reserved
+   
+   
+    UPPER
+    
+    non-reserved
+    reserved
+   
+   
+    USAGE
+    
+    reserved
+    reserved
+   
+   
+    USER
+    reserved
+    reserved
+    reserved
+   
+   
+    USER_DEFINED_TYPE_CATALOG
+    
+    non-reserved
+    
+   
+   
+    USER_DEFINED_TYPE_NAME
+    
+    non-reserved
+    
+   
+   
+    USER_DEFINED_TYPE_SCHEMA
+    
+    non-reserved
+    
+   
+   
+    USING
+    reserved
+    reserved
+    reserved
+   
+   
+    VACUUM
+    reserved
+    
+    
+   
+   
+    VALID
+    non-reserved
+    
+    
+   
+   
+    VALUE
+    
+    reserved
+    reserved
+   
+   
+    VALUES
+    non-reserved
+    reserved
+    reserved
+   
+   
+    VARCHAR
+    reserved
+    reserved
+    reserved
+   
+   
+    VARIABLE
+    
+    reserved
+    
+   
+   
+    VARYING
+    non-reserved
+    reserved
+    reserved
+   
+   
+    VERBOSE
+    reserved
+    
+    
+   
+   
+    VERSION
+    non-reserved
+    
+    
+   
+   
+    VIEW
+    non-reserved
+    reserved
+    reserved
+   
+   
+    WHEN
+    reserved
+    reserved
+    reserved
+   
+   
+    WHENEVER
+    
+    reserved
+    reserved
+   
+   
+    WHERE
+    reserved
+    reserved
+    reserved
+   
+   
+    WITH
+    non-reserved
+    reserved
+    reserved
+   
+   
+    WITHOUT
+    non-reserved
+    reserved
+    
+   
+   
+    WORK
+    non-reserved
+    reserved
+    reserved
+   
+   
+    WRITE
+    
+    reserved
+    reserved
+   
+   
+    YEAR
+    non-reserved
+    reserved
+    reserved
+   
+   
+    ZONE
+    non-reserved
+    reserved
+    reserved
+   
+  
+
+
+
+
index cbead926ca70f9be79f5fc18d9a92cbbcaeacb4c..4a02fab823f75874c91a8266d570f8eeffa904e6 100644 (file)
@@ -1,9 +1,9 @@
 
 
- syntax">
 SQL Syntax
+syntax">
SQL Syntax
 
   
    
@@ -11,505 +11,325 @@ $Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.31 2000/12/22 18:57:50 pete
    
   
 
+  Lexical Structure
+
+  
+   SQL input consists of a sequence of
+   commands.  A command is composed of a
+   sequence of tokens, which depend on the
+   syntax of the particular command, terminated by a semicolon
+   (;).  The end of the input stream also terminates a
+   command.
+  
+
   
-   SQL manipulates sets of data. The language is
-   composed of various key words. Arithmetic
-   and procedural expressions are allowed. We will cover these topics
-   in this chapter; subsequent chapters will include details on data
-   types, functions, and operators.
+   A token can be a key word, an
+   identifier, a quoted
+   identifier, a literal (or
+   constant), or a special character symbol.  Tokens are normally
+   separated by whitespace (space, tab, newline), but need not be if
+   there is no ambiguity (which is generally only the case if a
+   special character is adjacent to some other token type).
   
 
-  
-   Key Words
+  
+   Additionally, comments can occur in SQL
+   input.  They are not tokens, they are effectively equivalent to
+   whitespace.
+  
 
+  
    
-    SQL92 defines key words 
-    for the language
-    which have specific meaning. Some key words are
-    reserved, which indicates that they are
-    restricted to appear in only certain contexts. Other key words are
-    not restricted, which indicates that in certain 
-    contexts they
-    have a specific meaning but are not otherwise constrained.
+    For example, the following is (lexically) valid SQL input:
+
+SELECT * FROM MY_TABLE;
+UPDATE MY_TABLE SET A = 5;
+INSERT INTO MY_TABLE VALUES (3, 'hi there');
+
+    This is a sequence of three commands, one per line (although this
+    is not required; more than one command can be on a line, and
+    commands can be usefully split across lines).
    
+  
+
+  
+   The SQL syntax is not very consistent regarding what tokens
+   identify commands and which are operands or parameters.  The first
+   few tokens are generally the command name, so in the above example
+   we would usually speak of a SELECT, an
+   UPDATE, and an INSERT command.  But
+   for instance the UPDATE command always requires
+   a SET token to appear in a certain position, and
+   this particular variation of INSERT also
+   requires a VALUES in order to be complete.  The
+   precise syntax rules for each command are described in the
+   Reference Manual.
+  
+
+  
+   Identifiers and Key Words
 
    
-    Postgres implements an extended subset of the
-    SQL92 and SQL3 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 Postgres
+    Tokens such as SELECTUPDATE, or
+    VALUES in the example above are examples of
+    key words, that is, words that have a fixed
+    meaning in the SQL language.  The tokens MY_TABLE
+    and A are examples of
+    identifiers.  They identify names of
+    tables, columns, or other database objects, depending on the
+    command they are used in.  Therefore they are sometimes simply
+    called names.  Key words and identifiers have the
+    same lexical structure, meaning that one cannot know whether a
+    token is an identifier or a key word without knowing the language.
+    A complete list of key words can be found in 
+    linkend="sql-keywords-appendix">.
    
 
    
-    Information on SQL92 and SQL3 key words
-    is derived from .
+    SQL identifiers and key words must begin with a letter
+    (a-z) or underscore
+    (_).  Subsequent characters in an identifier or
+    key word can be letters, digits
+    (0-9), or underscores,
+    although the SQL standard will not define a key word that contains
+    digits or start or ends with an underscore.
    
 
-   
-    Reserved Key Words
-
-    
-     SQL92 and SQL3 have 
-     reserved key words which are not allowed 
-     as identifiers and not allowed in any usage other than as fundamental
-     tokens in SQL statements.
-     Postgres 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).
-    
-
-    
-     
-      Any string can be used as an identifier if surrounded by
-      double quotes (like this!). Some care is required since
-      such an identifier will be case sensitive
-      and will retain embedded whitespace and most other special characters.
-     
-    
-
-    
-     The following are Postgres
-     reserved words that are neither SQL92
-     nor SQL3 reserved words. These are allowed
-     to be present as column labels, but not as identifiers:
-
-     
-ABORT ANALYZE 
-BINARY 
-CLUSTER CONSTRAINT COPY
-DO 
-EXPLAIN EXTEND
-LISTEN LOAD LOCK 
-MOVE 
-NEW NONE NOTIFY 
-OFFSET 
-RESET 
-SETOF SHOW
-UNLISTEN UNTIL 
-VACUUM VERBOSE
-     
-    
-
-    
-     The following are Postgres
-     reserved words that are also SQL92 
-     or SQL3 reserved words, and that
-     are allowed to be present as column labels, but not as identifiers:
-
-     
-ALL ANY ASC BETWEEN BIT BOTH 
-CASE CAST CHAR CHARACTER CHECK COALESCE COLLATE COLUMN
- CONSTRAINT CROSS CURRENT CURRENT_DATE CURRENT_TIME
- CURRENT_TIMESTAMP CURRENT_USER 
-DEC DECIMAL DEFAULT DESC DISTINCT 
-ELSE END EXCEPT EXISTS EXTRACT 
-FALSE FLOAT FOR FOREIGN FROM FULL 
-GLOBAL GROUP 
-HAVING 
-IN INNER INTERSECT INTO IS 
-JOIN 
-LEADING LEFT LIKE LOCAL
-NATURAL NCHAR NOT NULL NULLIF NUMERIC 
-ON OR ORDER OUTER OVERLAPS 
-POSITION PRECISION PRIMARY PUBLIC
-REFERENCES RIGHT 
-SELECT SESSION_USER SOME SUBSTRING 
-TABLE THEN TO TRANSACTION TRIM TRUE
-UNION UNIQUE USER 
-VARCHAR 
-WHEN WHERE 
-     
-
-     The following are Postgres
-     reserved words that are also SQL92 
-     or SQL3 reserved words:
-
-     
-ADD ALTER AND AS 
-BEGIN BY
-CASCADE CLOSE COMMIT CREATE CURSOR
-DECLARE DEFAULT DELETE DESC DISTINCT DROP
-EXECUTE EXISTS EXTRACT
-FETCH FLOAT FOR FROM FULL
-GRANT 
-HAVING
-IN INNER INSERT INTERVAL INTO INOUT IS
-JOIN 
-LEADING LEFT LIKE LOCAL
-NAMES NATIONAL NATURAL NCHAR NO NOT NULL 
-ON OR OUT OUTER
-PARTIAL PRIMARY PRIVILEGES PROCEDURE PUBLIC
-REFERENCES REVOKE RIGHT ROLLBACK
-SELECT SESSION SET SUBSTRING
-TO TRAILING TRIM 
-UNION UNIQUE UPDATE USING
-VALUES VARCHAR VARYING VIEW
-WHERE WITH WITHOUT WORK 
-     
-    
-
-    
-     The following are SQL92 reserved key words that
-     are not Postgres reserved key words, but that
-     if used as function names are always translated into the function
-     CHAR_LENGTH:
-
-     
-CHARACTER_LENGTH
-     
-    
-
-    
-     The following are SQL92 or SQL3 
-     reserved key words that
-     are not Postgres reserved key words, but
-     if used as type names are always translated into an alternate, native type:
-
-     
-BOOLEAN DOUBLE FLOAT INT INTEGER INTERVAL REAL SMALLINT
-     
-    
-
-    
-     The following are not keywords of any kind, but when used in the
-     context of a type name are translated into a native
-     Postgres type, and when used in the
-     context of a function name are translated into a native function:
-
-     
-DATETIME TIMESPAN
-     
-
-     (translated to TIMESTAMP and INTERVAL,
-     respectively). This feature is intended to help with
-     transitioning to version 7.0, and will be removed in a future release.
-    
-
-    
-     The following are either SQL92
-     or SQL3 reserved key words
-     that are not key words in Postgres.
-     These have no proscribed usage in Postgres
-     at the time of writing (version 7.0) but may become reserved key words in the
-     future:
-
-     
-      
-       Some of these key words represent functions in SQL92.
-       These functions are defined in Postgres,
-       but the parser does not consider the names to be key words and they are allowed
-       in other contexts.
-      
-     
-
-     
-ALLOCATE ARE ASSERTION AT AUTHORIZATION AVG 
-BIT_LENGTH
-CASCADED CATALOG CHAR_LENGTH CHARACTER_LENGTH COLLATION
- CONNECT CONNECTION CONTINUE CONVERT CORRESPONDING COUNT
- CURRENT_SESSION
-DATE DEALLOCATE DEC DESCRIBE DESCRIPTOR
- DIAGNOSTICS DISCONNECT DOMAIN 
-ESCAPE EXCEPT EXCEPTION EXEC EXTERNAL 
-FIRST FOUND
-GET GO GOTO 
-IDENTITY INDICATOR INPUT INTERSECT
-LAST LOWER 
-MAX MIN MODULE 
-OCTET_LENGTH OPEN OUTPUT OVERLAPS 
-PREPARE PRESERVE 
-ROWS
-SCHEMA SECTION SESSION SIZE SOME 
- SQL SQLCODE SQLERROR SQLSTATE SUM SYSTEM_USER
-TEMPORARY TRANSLATE TRANSLATION 
-UNKNOWN UPPER USAGE
-VALUE 
-WHENEVER WRITE
-     
-    
-   
-
-   
-    Non-reserved Keywords
-
-    
-     SQL92 and SQL3 have 
-     non-reserved keywords which have
-     a prescribed meaning in the language but which are also allowed
-     as identifiers.
-     Postgres has additional keywords
-     which allow similar unrestricted usage.
-     In particular, these keywords
-     are allowed as column or table names.
-    
-
-    
-     The following are Postgres
-     non-reserved key words that are neither SQL92
-     nor SQL3 non-reserved key words:
-
-     
-ACCESS AFTER AGGREGATE 
-BACKWARD BEFORE 
-CACHE COMMENT CREATEDB CREATEUSER CYCLE
-DATABASE DELIMITERS 
-EACH ENCODING EXCLUSIVE
-FORCE FORWARD FUNCTION 
-HANDLER
-INCREMENT INDEX INHERITS INSENSITIVE INSTEAD ISNULL
-LANCOMPILER LOCATION 
-MAXVALUE MINVALUE MODE
-NOCREATEDB NOCREATEUSER NOTHING NOTIFY NOTNULL 
-OIDS OPERATOR 
-PASSWORD PROCEDURAL
-RECIPE REINDEX RENAME RETURNS ROW RULE
-SEQUENCE SERIAL SHARE START STATEMENT STDIN STDOUT 
-TEMP TRUSTED 
-UNLISTEN UNTIL 
-VALID VERSION
-     
-    
-
-    
-     The following are Postgres
-     non-reserved key words that are SQL92
-     or SQL3 reserved key words:
-
-     
-ABSOLUTE ACTION
-CHARACTERISTICS CONSTRAINTS
-DAY DEFERRABLE DEFERRED 
-HOUR
-IMMEDIATE INITIALLY INSENSITIVE ISOLATION 
-KEY 
-LANGUAGE LEVEL 
-MATCH MINUTE MONTH
-NEXT 
-OF ONLY OPTION 
-PATH PENDANT PRIOR PRIVILEGES 
-READ RELATIVE RESTRICT 
-SCHEMA SCROLL SECOND
-TIME TIMESTAMP TIMEZONE_HOUR TIMEZONE_MINUTE TRIGGER 
-YEAR
-ZONE
-     
-    
-
-    
-     The following are Postgres
-     non-reserved key words that are also either SQL92
-     or SQL3 non-reserved key words:
-
-     
-COMMITTED SERIALIZABLE TYPE
-     
-    
-
-    
-     The following are either SQL92
-     or SQL3 non-reserved key words that are not
-     key words of any kind in Postgres:
-
-     
-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 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 SERVER_NAME SPACE SUBCLASS_ORIGIN
-TABLE_NAME
-UNCOMMITTED UNNAMED
-     
-    
-   
-  
-
-  
-   Comments
-
    
-    A comment
-    is an arbitrary sequence of characters beginning with double dashes
-    and extending to the end of the line, e.g.:
-
-    
--- This is a standard SQL comment
-    </programlisting>
+    The system uses no more than NAMEDATALEN-1
+    characters of an identifier; longer names can be written in
+    commands, but they will be truncated.  By default,
+    NAMEDATALEN is 32 so the maximum identifier length
+    is 31 (but at the time the system is built,
+    NAMEDATALEN can be changed in
+    <filename>src/include/postgres_ext.h).
    
 
    
-    We also support C-style block comments, e.g.:
-
-    
-/* multi-line comment
- * with nesting: /* nested block comment */
- */
-    
-
-    where the comment begins with "/*" and extends
-    to the matching occurrence of "*/". These block
-    comments nest, as specified in SQL99, so that one can comment out
-    larger blocks of code that may contain existing block comments.
+    Identifier and key word names are case insensitive.  Therefore
+
+UPDATE MY_TABLE SET A = 5;
+
+    can equivalently be written as
+
+uPDaTE my_TabLE SeT a = 5;
+
+    A good convention to adopt is perhaps to write key words in upper
+    case and names in lower case, e.g.,
+
+UPDATE my_table SET a = 5;
+
    
-  
-
-  
-   Names
 
    
-    Names in SQL must begin with a letter
-    (a-z) or underscore
-    (_).
-    Subsequent characters in a name can be letters, digits
-    (0-9),
-    or underscores.  The system uses no more than NAMEDATALEN-1 characters
-    of a name; longer names can be written in queries, but they will be
-    truncated.
-    By default, NAMEDATALEN is 32 so the maximum name length is 31 (but
-    at the time the system is built, NAMEDATALEN can be changed in
-    src/include/postgres_ext.h).
+    There is a second kind of identifier:  the delimited
+    identifier or quoted
+    identifier.  It is formed by enclosing an arbitrary
+    sequence of characters in double-quotes
+    (").  A delimited
+    identifier is always an identifier, never a key word.  So
+    "select" could be used to refer to a column or
+    table named select, whereas an unquoted
+    select would be taken as part of a command and
+    would therefore provoke a parse error when used where a table or
+    column name is expected.  The example can be written with quoted
+    identifiers like so:
+
+UPDATE "my_table" SET "a" = 5;
+
    
 
    
-    Names containing other characters may be formed by surrounding them
-    with double quotes (").  For example, table or column
-    names may contain
-    otherwise disallowed characters such as spaces, ampersands, etc. if
-    quoted.  Quoting a name also makes it case-sensitive,
-    whereas unquoted names are always folded to lower case.  For example,
-    the names FOOfoo
-    and "foo" are
-    considered the same by Postgres, but
-    "Foo" is a different name.
+    Quoted identifiers can contain any character other than a double
+    quote itself.  This allows constructing table or column names that
+    would otherwise not be possible, such as ones containing spaces or
+    ampersands.  The length limitation still applies.
    
 
    
-    Double quotes can also be used to protect a name that would otherwise
-    be taken to be an SQL keyword.  For example, IN
-    is a keyword but "IN" is a name.
+    Quoting an identifier also makes it case-sensitive, whereas
+    unquoted names are always folded to lower case.  For example, the
+    identifiers FOOfoo and
+    "foo" are considered the same by
+    Postgres, but "Foo"
+    and "FOO" are different from these three and
+    each other.
+    
+     
+      This is incompatible with SQL, where unquoted names are folded to
+      upper case.  Thus, foo is equivalent to
+      "FOO".  If you want to write portable
+      applications you are advised to always quote a particular name or
+      never quote it.
+     
+    
    
-  
+  
+
 
-  1 id="sql-constants">
+  2 id="sql-syntax-constants">
    Constants
 
    
-    There are three kinds of implicitly typed constants
-    in Postgres: strings, integers, 
-    and floating point numbers.  Constants can
-    also be specified with explicit types, which can enable more
-    accurate representation and more efficient handling by the
-    backend. The implicit constants are described below; explicit
+    There are four kinds of implicitly typed
+    constants in Postgres:
+    strings, bit strings, integers, and floating point numbers.
+    Constants can also be specified with explicit types, which can
+    enable more accurate representation and more efficient handling by
+    the system. The implicit constants are described below; explicit
     constants are discussed afterwards.
    
 
-   2>
+   3>
     String Constants
 
     
-     Strings
-     in SQL are arbitrary sequences of ASCII characters bounded by single
-     quotes ("'", e.g. 'This is a string').
-     SQL92 allows single quotes to be embedded in strings by typing two 
-     adjacent single quotes (e.g. 'Dianne''s horse').
-     In Postgres single quotes may alternatively
-     be escaped with a backslash ("\", e.g.
-     'Dianne\'s horse').  To include a
+     A string constant in SQL is an arbitrary sequence of characters
+     bounded by single quotes ('), e.g., 'This
+     is a string'.  SQL allows single quotes to be embedded
+     in strings by typing two adjacent single quotes (e.g.,
+     'Dianne''s horse').  In
+     Postgres single quotes may
+     alternatively be escaped with a backslash (\,
+     e.g., 'Dianne\'s horse').
+    
+
+    
+     C-style backslash escapes are also available:
+     \b is a backspace, \f is a
+     form feed, \n is a newline,
+     \r is a carriage return, \t
+     is a tab, and \xxx,
+     where xxx is an octal number, is the
+     character with the corresponding ASCII code.  Any other character
+     following a backslash is taken literally.  Thus, to include a
      backslash in a string constant, type two backslashes.
-     Non-printing characters may also be embedded within strings by
-     prepending them with a backslash
-     (e.g. '\tab').
     
 
-   
+    
+     The character with the code zero cannot be in a string constant.
+    
 
-   
-    Integer Constants
+    
+     Two string constants that are only separated by whitespace
+     with at least one newline are concatenated
+     and effectively treated as if the string had been written in one
+     constant.  For example:
+
+SELECT 'foo'
+'bar';
+
+     is equivalent to
+
+SELECT 'foobar';
+
+     but
+
+SELECT 'foo'      'bar';
+
+     is not valid syntax.
+    
+   
+
+   
+    Bit String Constants
 
     
-     Integer constants
-     in SQL are sequences of ASCII digits with no decimal point.
-     The range of legal values depends on which integer datatype is
-     used, but the plain integer type accepts values
-     ranging from -2147483648 to +2147483647.
+     Bit string constants look like string constants with a
+     B (upper or lower case) immediately before the
+     opening quote (no intervening whitespace), e.g.,
+     B'1001'.  The only characters allowed within
+     bit string constants are 0 and
+     1.  Bit strings constants can be continued
+     across lines in the same way as regular string constants.
     
-   2>
+   3>
 
-   2>
-    <span class="marked">Floating Point</span> Constants
+   3>
+    <span class="marked">Integer</span> Constants
 
     
-     Floating point constants
-     consist of an integer part, a decimal point, and a fraction part or
-     scientific notation of the following format:
+     Integer constants in SQL are sequences of decimal digits (0
+     though 9) with no decimal point.  The range of legal values
+     depends on which integer data type is used, but the plain
+     integer type accepts values ranging from -2147483648
+     to +2147483647.  (The optional plus or minus sign is actually a
+     separate unary operator and not part of the integer constant.)
+    
+   
 
-     
-{dig}.{dig} [e [+-] {dig}]
-     
+   
+    Floating Point Constants
 
-     where dig is one or more digits.
-     You must include at least one dig after the
-     period and after the [+-] if you use those options.  An exponent with
-     a missing mantissa has a mantissa of 1 inserted.  There may be no
-     extra characters embedded in the string.
+    
+     Floating point constants are accepted in these general forms:
+
+digits.digitse+-digits
+digits.digitse+-digits
+digitse+-digits
+
+     where digits is one or more decimal
+     digits.  At least one digit must be before or after the decimal
+     point and after the e if you use that option.
+     Thus, a floating point constant is distinguished from an integer
+     constant by the presence of either the decimal point or the
+     exponent clause (or both).  There must not be a space or other
+     characters embedded in the constant.
     
 
+    
+     
+      These are some examples of valid floating point constants:
+
+3.5
+4.
+.001
+5e2
+1.925e-3
+
+     
+    
+
     
-     Floating point constaints are of type
-     float8float4 can be specified
-     explicitly by using SQL92 string notation or
+     Floating point constants are of type DOUBLE
+     PRECISION. REAL can be specified explicitly
+     by using SQL string notation or
      Postgres type notation:
 
-     
-float4 '1.23'  -- string style
-'1.23'::float4 -- Postgres (historical) style
+
+REAL '1.23'  -- string style
+'1.23'::REAL -- Postgres (historical) style
      
     
-   2>
+   3>
 
-   2>
-    Constants of <span class="marked">Postgres User-Defined</span> Types
+   3>
+    Constants of <span class="marked">Other</span> Types
 
     
-     A constant of an
-     arbitrary
-     type can be entered using any one of the following notations:
-
-     
+     A constant of an arbitrary type can be
+     entered using any one of the following notations:
+
 type 'string'
 'string'::type
 CAST ( 'string' AS type )
-     
-
-     The value inside the string is passed to the input
-     conversion routine for the type called
-     type. The result is a
-     constant of the indicated type.  The explicit typecast may be omitted
-     if there is no ambiguity as to the type the constant must be, in which
-     case it is automatically coerced.
+
+     The value inside the string is passed to the input conversion
+     routine for the type called type. The
+     result is a constant of the indicated type.  The explicit type
+     cast may be omitted if there is no ambiguity as to the type the
+     constant must be (for example, when it is passed as an argument
+     to a non-overloaded function), in which case it is automatically
+     coerced.
     
 
     
      It is also possible to specify a type coercion using a function-like
      syntax:
-
-     
+
 typename ( value )
-     
-
+
      although this only works for types whose names are also valid as
      function names.  (For example, double precision
      can't be used this way --- but the equivalent float8
@@ -517,52 +337,222 @@ CAST ( 'string' AS type )
     
 
     
-     The ::CAST(), and function-call
-     syntaxes can also be used to specify run-time type conversions.  But
-     the form type
-     'string' can only be used to specify the
-     type of a literal constant.
+     The ::CAST(), and
+     function-call syntaxes can also be used to specify the type of
+     arbitrary expressions, but the form
+     type
+     'string' can only be used to specify
+     the type of a literal constant.
     
-   2>
+   3>
 
-   2>
+   3>
     Array constants
 
     
-     Array constants
-     are n-dimensional arrays of any Postgres datatype.
      The general format of an array constant is the following:
-
-     
-{ val1 delim val2 delim ... }
-     
-
-     where delim
-     is the delimiter character for the type, as recorded in its
-     pg_type class entry.
-     (For all built-in types, this is the comma character ",".)
-     Each val is either a constant
-     of the array element type, or a sub-array.
-     An example of an array constant is
-
-     
-{{1,2,3},{4,5,6},{7,8,9}}
-     
-
+
+'{ val1 delim val2 delim ... }'
+
+     where delim is the delimiter character
+     for the type, as recorded in its pg_type
+     entry.  (For all built-in types, this is the comma character
+     ",".)  Each val is either a constant
+     of the array element type, or a sub-array.  An example of an
+     array constant is
+
+'{{1,2,3},{4,5,6},{7,8,9}}'
+
      This constant is a two-dimensional, 3 by 3 array consisting of three
      sub-arrays of integers.
     
 
     
      Individual array elements can be placed between double-quote
-     marks ("to avoid ambiguity problems with respect to
-     white space.
-     Without quote marks, the array-value parser will skip leading white space.
+     marks (" to avoid ambiguity
+     problems with respect to white space.  Without quote marks, the
+     array-value parser will skip leading white space.
     
-   
-  
 
-  
+    
+     (Array constants are actually only a special case of the generic
+     type constants discussed in the previous section.  The constant
+     is initially treated as a string and passed to the array input
+     conversion routine.  An explicit type specification might be
+     necessary.)
+    
+   
+  
+
+
+  
+   Operators
+
+   
+    An operator is a sequence of up to NAMEDATALEN-1
+    (31 by default) characters from the following list:
+
++ - * / < > = ~ ! @ # % ^ & | ` ? $
+
+
+    There are a few restrictions on operator names, however:
+    
+     
+      
+       "$" (dollar) cannot be a single-character operator, although it
+       can be part of a multi-character operator name.
+      
+     
+
+     
+      
+       -- and /* cannot appear
+       anywhere in an operator name, since they will be taken as the
+       start of a comment.
+      
+     
+
+     
+      
+       A multi-character operator name cannot end in "+" or "-",
+       unless the name also contains at least one of these characters:
+
+~ ! @ # % ^ & | ` ? $
+
+       For example, @- is an allowed operator name,
+       but *- is not.  This restriction allows
+       Postgres to parse SQL-compliant
+       queries without requiring spaces between tokens.
+      
+     
+    
+   
+
+   
+    When working with non-SQL-standard operator names, you will usually
+    need to separate adjacent operators with spaces to avoid ambiguity.
+    For example, if you have defined a left-unary operator named "@",
+    you cannot write X*@Y; you must write
+    X* @Y to ensure that
+    Postgres reads it as two operator names
+    not one.
+   
+  
+
+  
+   Special Characters
+
+  
+   Some characters that are not alphanumeric have a special meaning
+   that is different from being an operator.  Details on the usage can
+   be found at the location where the respective syntax element is
+   described.  This section only exists to advise the existence and
+   summarize the purposes of these characters.
+
+   
+    
+     
+      A dollar sign ($) followed by digits is used
+      to represent the positional parameters in the body of a function
+      definition.  In other contexts the dollar sign may be part of an
+      operator name.
+     
+    
+
+    
+     
+      Parentheses (()) have their usual meaning to
+      group expressions and enforce precedence.  In some cases
+      parentheses are required as part of the fixed syntax of a
+      particular SQL command.
+     
+    
+
+    
+     
+      Brackets ([]) are used to select the elements
+      of an array.  See  for more information
+      on arrays.
+     
+    
+
+    
+     
+      Commas (,) are used in some syntactical
+      constructs to separate the elements of a list.
+     
+    
+
+    
+     
+      The semicolon (;) terminates an SQL command.
+      It cannot appear anywhere within a command, except when quoted
+      as a string constant or identifier.
+     
+    
+
+    
+     
+      The colon (:) is used to select
+      slices from arrays. (See 
+      linkend="arrays">.)  In certain SQL dialects (such as Embedded
+      SQL), the colon is used to prefix variable names.
+     
+    
+
+    
+     
+      The asterisk (*) has a special meaning when
+      used in the SELECT command or with the
+      COUNT aggregate function.
+     
+    
+
+    
+     
+      The period (.) is used in floating point
+      constants, and to separate table and column names.
+     
+    
+   
+
+   
+  
+
+  
+   Comments
+
+   
+    A comment is an arbitrary sequence of characters beginning with
+    double dashes and extending to the end of the line, e.g.:
+
+-- This is a standard SQL92 comment
+
+   
+
+   
+    Alternatively, C-style block comments can be used:
+
+/* multi-line comment
+ * with nesting: /* nested block comment */
+ */
+
+    where the comment begins with /* and extends to
+    the matching occurrence of */. These block
+    comments nest, as specified in SQL99 but unlike C, so that one can
+    comment out larger blocks of code that may contain existing block
+    comments.
+   
+
+   
+    A comment is removed from the input stream before further syntax
+    analysis and is effectively replaced by whitespace.
+   
+  
+
+
+  
    Fields and Columns
 
    
@@ -664,18 +654,6 @@ CAST ( 'string' AS type )
    
   
 
-  
-   Operators
-
-   
-    Any built-in or user-defined operator may be used in SQL.
-    For the list of built-in operators consult .
-    For a list of user-defined operators consult your system administrator
-    or run a query on the pg_operator class.
-    Parentheses may be used for arbitrary grouping of operators in expressions.
-   
-  
-
   
    Expressions
 
index e2f78744839e0ce9d6d214244465ff8d05c701ec..d1275e017330776d075292df6e47443cea9fe54f 100644 (file)
@@ -1,5 +1,5 @@
 
 
 
@@ -62,6 +62,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/user.sgml,v 1.22 2000/12/16 02:29:36
  
 
  &datetime;
+ &keywords;
 
  &biblio;