SQL Quick Syntax Guide Version 52
SQL Quick Syntax Guide Version 52
November 2002
Part No. 000-9123
Note:
Before using this information and the product it supports, read the information in the
appendix entitled “Notices.”
This document contains proprietary information of IBM. It is provided under a license agreement and is
protected by copyright law. The information contained in this publication does not include any product
warranties, and any statements provided in this manual should not be interpreted as such.
When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information
in any way it believes appropriate without incurring any obligation to you.
© Copyright International Business Machines Corporation 1996, 2002. All rights reserved.
US Government User Restricted Rights—Use, duplication or disclosure restricted by GSA ADP Schedule
Contract with IBM Corp.
Table of Contents
Introduction
In This Introduction . . . . . . . . . . . . . . . . . 3
About This Manual . . . . . . . . . . . . . . . . . . 3
Syntax Conventions . . . . . . . . . . . . . . . . 3
Table of Contents v
SYSTEM . . . . . . . . . . . . . . . . . . . . . 3-11
TRACE . . . . . . . . . . . . . . . . . . . . . 3-12
WHILE . . . . . . . . . . . . . . . . . . . . . 3-12
SPL Expression . . . . . . . . . . . . . . . . . . . 3-13
Appendix A Notices
Introduction
In This Introduction . . . . . . . . . . . . . . . . . . 3
About This Manual . . . . . . . . . . . . . . . . . . . 3
Syntax Conventions . . . . . . . . . . . . . . . . . 3
2 IBM Informix SQL Quick Syntax Guide
In This Introduction
This introduction provides an overview of the information in this manual
and describes the conventions it uses.
■ SQL statements
■ SQL segments
■ Stored Procedure Language (SPL) statements
Syntax Conventions
Syntax diagrams describe the format of SQL statements or commands,
including alternative forms of a statement, required and optional parts of the
statement, and so forth. Syntax diagrams have their own conventions, which
are defined in detail and illustrated in this section. SQL statements are listed
in their entirety in the IBM Informix Guide to SQL: Reference, although some
statements may appear in other manuals.
Introduction 3
Syntax Conventions
A diagram begins at the upper left with a keyword. It ends at the upper right
with a vertical line. Between these points you can trace any path that does not
stop or back up. Each path describes a valid form of the statement.
(.,;+*-/) Punctuation and mathematical notations are literal symbols that you
must enter exactly as shown.
" " Double quotes are literal symbols that you must enter as shown. You
can replace a pair of double quotes with a pair of single quotes, if you
prefer. You cannot mix double and single quotes.
variable A word in italics represents a value that you must supply. The nature
of the value is explained immediately following the diagram unless
the variable appears in a box. In that case, the page number of the
detailed explanation follows the variable name.
I4GL A code in an icon is a signal warning you that this path is valid only
for some products or under certain conditions. The codes indicate the
products or conditions that support the path. The following codes are
used:
SE
SE This path is valid only for IBM Informix SE.
STAR
STAR This path is valid only for IBM Informix STAR.
STAR
INET This path is valid only for IBM Informix NET.
ISQL
ISQL This path is valid only for IBM Informix SQL.
ESQL
ESQL This path is valid for SQL statements in all the following
embedded language products: IBM Informix ESQL/C
and IBM Informix ESQL/COBOL.
E/C
E/C This path is valid only for IBM Informix ESQL/C.
E/CO
E/C This path is valid only for IBM Informix ESQL/COBOL.
E/F
E/C This path is valid only for INFORMIX-ESQL/FORTRAN.
DB
E/C This path is valid only for DB-Access.
STAR
SPL This path is valid only if you are using Informix Stored
Procedure Language (SPL).
A shaded option is the default. Even if you do not explicitly type the
ALL
option, it will be in effect unless you choose another option.
Introduction 5
Syntax Conventions
IN
A branch below the main line indicates an optional path.
NOT
variable
1 column key
In the IBM Informix Guide to SQL: Reference, icons that appear in the left margin
indicate that the accompanying shaded text is valid only for some products
or under certain conditions. In addition to the icons described in the
preceding list, you may encounter the following icons in the left margin:
ANSI This icon indicates that the functionality described in the shaded text
is valid only if your database is ANSI-compliant.
X/O This icon indicates that the functionality described in the shaded text
conforms to X/Open standards for dynamic SQL. This functionality
is available when you compile your embedded-language application
with the -xopen flag.
Figure 1 shows the elements of a syntax diagram for the CREATE DATABASE
statement.
Figure 1
Elements of a syntax diagram
Reference Boxes
Terminator
Signals
CREATE DATABASE database name
Punctuation
SE Log Clause
MODE ANSI
Subdiagrams
OL Log Clause
WITH LOG
BUFFERED
To construct a statement using this diagram, start at the top left with the
keywords CREATE DATABASE. Then follow the diagram to the right,
proceeding through the options that you want. The diagram conveys the
following information:
1. You must type the words CREATE DATABASE.
2. You must supply a database name.
3. You can stop, taking the direct route to the terminator, or you can
take one or more of the optional paths.
4. If desired, you can designate a dbspace by typing the word IN and a
dbspace name.
Introduction 7
Syntax Conventions
5. If desired, you can specify logging. Here, you are constrained by the
database server with which you are working.
■ If you are using IBM Informix OnLine, go to the subdiagram
named OL Log Clause. Follow the subdiagram by typing the
keyword WITH, then choosing and typing either LOG, BUFFERED
LOG, or LOG MODE ANSI. Then, follow the arrow back to the
main diagram.
■ If you are using IBM Informix SE, go to the subdiagram named SE
Log Clause. Follow the subdiagram by typing the keywords
WITH LOG IN, typing a double quote, supplying a pathname,
and closing the quotes. You can then choose the MODE ANSI
option below the line or continue to follow the line across.
6. Once you are back at the main diagram, you come to the terminator.
Your CREATE DATABASE statement is complete.
SQL Statements
1
ALLOCATE DESCRIPTOR . . . . . . . . . . . . . . . . 1-5
ALTER INDEX . . . . . . . . . . . . . . . . . . . . 1-5
ALTER TABLE . . . . . . . . . . . . . . . . . . . . 1-6
BEGIN WORK . . . . . . . . . . . . . . . . . . . . 1-11
CHECK TABLE . . . . . . . . . . . . . . . . . . . . 1-11
CLOSE . . . . . . . . . . . . . . . . . . . . . . . 1-12
CLOSE DATABASE . . . . . . . . . . . . . . . . . . 1-12
COMMIT WORK . . . . . . . . . . . . . . . . . . . 1-12
CREATE AUDIT FOR . . . . . . . . . . . . . . . . . . 1-13
CREATE DATABASE . . . . . . . . . . . . . . . . . . 1-13
CREATE INDEX . . . . . . . . . . . . . . . . . . . . 1-14
CREATE PROCEDURE . . . . . . . . . . . . . . . . . 1-15
CREATE PROCEDURE FROM . . . . . . . . . . . . . . . 1-17
CREATE SCHEMA AUTHORIZATION . . . . . . . . . . . 1-17
CREATE SYNONYM . . . . . . . . . . . . . . . . . . 1-18
CREATE TABLE . . . . . . . . . . . . . . . . . . . . 1-19
CREATE VIEW . . . . . . . . . . . . . . . . . . . . 1-22
DATABASE . . . . . . . . . . . . . . . . . . . . . 1-22
DEALLOCATE DESCRIPTOR . . . . . . . . . . . . . . . 1-23
DECLARE . . . . . . . . . . . . . . . . . . . . . . 1-24
DELETE FROM . . . . . . . . . . . . . . . . . . . . 1-25
DESCRIBE . . . . . . . . . . . . . . . . . . . . . . 1-25
DROP AUDIT FOR . . . . . . . . . . . . . . . . . . . 1-26
DROP DATABASE . . . . . . . . . . . . . . . . . . . 1-26
DROP INDEX. . . . . . . . . . . . . . . . . . . . . 1-26
DROP PROCEDURE . . . . . . . . . . . . . . . . . . 1-27
DROP SYNONYM . . . . . . . . . . . . . . . . . . . 1-27
DROP TABLE . . . . . . . . . . . . . . . . . . . . . 1-27
DROP VIEW . . . . . . . . . . . . . . . . . . . . . 1-28
EXECUTE . . . . . . . . . . . . . . . . . . . . . . 1-28
EXECUTE IMMEDIATE . . . . . . . . . . . . . . . . . 1-29
EXECUTE PROCEDURE . . . . . . . . . . . . . . . . . 1-29
FETCH . . . . . . . . . . . . . . . . . . . . . . . 1-30
FLUSH . . . . . . . . . . . . . . . . . . . . . . . 1-31
FREE . . . . . . . . . . . . . . . . . . . . . . . . 1-31
GET DESCRIPTOR . . . . . . . . . . . . . . . . . . . 1-32
GRANT . . . . . . . . . . . . . . . . . . . . . . . 1-33
INFO . . . . . . . . . . . . . . . . . . . . . . . . 1-35
INSERT INTO. . . . . . . . . . . . . . . . . . . . . 1-36
LOAD FROM . . . . . . . . . . . . . . . . . . . . . 1-38
LOCK TABLE . . . . . . . . . . . . . . . . . . . . . 1-39
OPEN . . . . . . . . . . . . . . . . . . . . . . . 1-39
OUTPUT TO . . . . . . . . . . . . . . . . . . . . . 1-40
PREPARE . . . . . . . . . . . . . . . . . . . . . . 1-40
ALLOCATE
DESCRIPTOR " descriptor "
+ ALTER INDEX
Figure 1-2
ALTER INDEX
Index Name
ALTER INDEX p. 2-13 TO CLUSTER
NOT
+ ALTER TABLE
Figure 1-3
ALTER TABLE
ADD CONSTRAINT
Clause p. 1-10
DROP CONSTRAINT
Clause p. 1-10
OL
MODIFY NEXT SIZE
Clause p. 1-11
LOCK MODE
Clause p. 1-11
ADD Clause
Add Column
ADD Clause p. 1-7
( Add Column )
Clause p. 1-7
Add Column
Clause
new
column Data
name Type
NOT
,
p. 2-7
DB NULL
Constraint
ESQL def. (Subset)
DEFAULT
Clause
column
BEFORE name
DEFAULT
Clause
DEFAULT literal
NULL
CURRENT
p. 2-10
DATETIME
Field Qualifier
p. 2-8
USER
p. 2-10
TODAY
OL p. 2-10
SITENAME
p. 2-10
DBSERVERNAME
p. 2-10
Constraint
def. (Subset)
UNIQUE
DB +
ESQL
Constraint
PRIMARY CONSTRAINT Name
KEY p. 2-5
REFERENCES
Clause
CHECK
Clause
p. 1-9
REFERENCES
Clause Table
REFERENCES Name
p. 2-19
,
( column )
CHECK Clause
CHECK ( Condition )
p. 2-3
DROP Clause
( column name )
MODIFY Clause
Modify Column
MODIFY Clause
( Modify Column )
Clause
Modify Column
Clause
column Data Type
name p. 2-7 ,
NOT
DB NULL
Constraint
ESQL def. (Subset)
p. 1-7
DEFAULT
Clause
p. 1-7
ADD
CONSTRAINT
Clause
Constraint
ADD CONSTRAINT Definition
( Constraint )
Definition
Constraint ,
Definition
UNIQUE ( column )
DB +
ESQL
Constraint
CONSTRAINT Name
PRIMARY
KEY p. 2-5
,
REFERENCES
FOREIGN ( column ) Clause
KEY p. 1-8
CHECK
Clause
DROP
CONSTRAINT
Clause
Constraint
DROP CONSTRAINT Name
p. 2-5
,
( Constraint )
Name
p. 2-5
MODIFY
NEXT SIZE
Clause
MODIFY NEXT SIZE kbytes
LOCK MODE
Clause
LOCK MODE ( PAGE )
ROW
+ BEGIN WORK
Figure 1-4
BEGIN WORK
BEGIN WORK
SE CHECK TABLE
DB
ISQL
Figure 1-5
CHECK TABLE
Table
CHECK TABLE Name
p. 2-19
I4GL CLOSE
ESQL
Figure 1-6
CLOSE
cursor
CLOSE name
+ CLOSE DATABASE
Figure 1-7
CLOSE DATABASE
CLOSE DATABASE
COMMIT WORK
Figure 1-8
COMMIT WORK
COMMIT WORK
Figure 1-9
CREATE AUDIT FOR
Synonym
Name
p. 2-18
+ CREATE DATABASE
Figure 1-10
CREATE DATABASE
CREATE Database
DATABASE Name
p. 2-6
OL IN dbspace SE SE Log Clause
OL OL Log Clause
SE Log Clause
WITH LOG IN "pathname"
MODE ANSI
OL Log Clause
WITH LOG
BUFFERED
+ CREATE INDEX
Figure 1-11
CREATE INDEX
Index ON
CREATE INDEX Name Clause
p. 2-13
UNIQUE CLUSTER
DISTINCT
,
ON Clause
ON Table ( column name )
Name
p. 2-19
ASC
Synonym DESC
Name
p. 2-18
DB CREATE PROCEDURE
ESQL
CREATE
PROCEDURE
Procedure ( ) Statement
PROCEDURE Name Block
p. 2-17 , p. 1-16
DBA RETURNING
Parameter Clause
END ;
PROCEDURE ,
WITH
DOCUMENT Quoted String LISTING IN " pathname "
p. 2-17
Parameter
variable SQL Data Type
name (Subset)
p. 2-7 default
value
LIKE table . column
REFERENCES BYTE
TEXT DEFAULT
NULL
,
RETURNING
Clause
RETURNING SQL Data Type ;
(Subset)
p. 2-7
REFERENCES BYTE
TEXT
Statement Block
CALL
DEFINE ON Statement
Statement EXCEPTION p. 3-3
p. 3-4 Statement
p. 3-10 CONTINUE
Statement
p. 3-3
EXECUTE PROCEDURE
Statement
p. 1-29
EXIT
Statement
p. 3-5
FOR
Statement
p. 3-6
FOREACH
Statement
p. 3-7
IF
Statement
p. 3-8
LET
Statement
p. 3-10
RAISE EXCEPTION
Statement
p. 3-11
RETURN
Statement
p. 3-11
SYSTEM
Statement
p. 3-11
TRACE
Statement
p. 3-12
WHILE
Statement
p. 3-12
SQL Statement
Statement
BEGIN Block END
Figure 1-13
CREATE PROCEDURE FROM
CREATE
PROCEDURE " filename "
FROM
ESQL
variable
name
Figure 1-14
CREATE SCHEMA AUTHORIZATION
+ CREATE INDEX
p. 1-14
CREATE VIEW
p. 1-22
+ CREATE SYNONYM
GRANT
p. 1-33
+ CREATE SYNONYM
Figure 1-15
CREATE SYNONYM
Synonym
CREATE SYNONYM FOR Table Name
Name p. 2-19
p. 2-18
PUBLIC
View Name
p. 2-19
PRIVATE
CREATE TABLE
Figure 1-16
CREATE TABLE
, ,
CREATE Table Column Constraint
TABLE Name ( Definition Definition )
p. 2-19 p. 1-19 p. 1-21
Storage
Option
p. 1-21
, ,
temp Column Constraint
+ TEMP table ( Definition Definition )
TABLE name (Temp Table (Temp Table
Subset) Subset)
p. 1-19 p. 1-21
WITH NO LOG
Column Definition
Data Type
column p. 2-7
DEFAULT
Clause
DEFAULT Clause
DEFAULT literal
NULL
CURRENT
p. 2-10
DATETIME
Field Qualifier
p. 2-8
USER
p. 2-10
TODAY
p. 2-10
OL
SITENAME
p. 2-10
DBSERVERNAME
p. 2-10
Constraint
def. (Subset)
UNIQUE
DB +
ESQL Constraint
CONSTRAINT Name
PRIMARY p. 2-5
KEY
REFERENCES
Clause
p. 1-21
CHECK
Clause
p. 1-21
Constraint ,
Definitiion
UNIQUE ( column )
+
DB Constraint
CONSTRAINT Name
ESQL p. 2-5
PRIMARY ,
KEY
CHECK
Clause
REFERENCES
Clause
Table
REFERENCES Name
p. 2-19 ,
( column )
CHECK Clause
CHECK ( Condition )
p. 2-3
Storage Option
OL
SE IN "pathname"
Extent Option
LOCK MODE
Clause
LOCK MODE
PAGE
ROW
CREATE VIEW
Figure 1-17
CREATE VIEW
+ DATABASE
Figure 1-18
DATABASE
Database
DATABASE Name
p. 2-6
EXCLUSIVE
DEALLOCATE descriptor
DESCRIPTOR " "
descriptor
variable
I4GL DECLARE
ESQL
Figure 1-20
DECLARE
statement id
ESQL
+ statement id
variable
EXECUTE
PROCEDURE
Statement
p. 1-29
DELETE FROM
Figure 1-21
DELETE FROM
Table
DELETE FROM Name
p. 2-19
WHERE Condition
View p. 2-3
Name I4GL
p. 2-19 ESQL
cursor
Synonym CURRENT OF name
Name
p. 2-18
ESQL DESCRIBE
+
Figure 1-22
DESCRIBE
DESCRIBE USING
statement id SQL DESCRIPTOR " descriptor "
descriptor
statement E/C variable
id variable
INTO sqlda pointer
Figure 1-23
DROP AUDIT FOR
Table Name
DROP AUDIT FOR p. 2-19
Synonym
Name
p. 2-18
+ DROP DATABASE
Figure 1-24
DROP DATABASE
Database
DROP DATABASE Name
p. 2-6
+ DROP INDEX
Figure 1-25
DROP INDEX
Index
DROP INDEX Name
p. 2-13
DB DROP PROCEDURE
ESQL
Figure 1-26
DROP PROCEDURE
DROP Procedure
PROCEDURE Name
p. 2-17
+ DROP SYNONYM
Figure 1-27
DROP SYNONYM
Synonym
DROP SYNONYM Name
p. 2-18
+ DROP TABLE
Figure 1-28
DROP TABLE
Synonym
Name
p. 2-18
+ DROP VIEW
Figure 1-29
DROP VIEW
Synonym
Name
p. 2-18
I4GL EXECUTE
ESQL
Figure 1-30
EXECUTE
EXECUTE statement id
,
ESQL
USING variable name
statement
id variable ESQL
Figure 1-31
EXECUTE IMMEDIATE
Quoted
EXECUTE String
IMMEDIATE p. 2-17
DB EXECUTE PROCEDURE
ESQL
Figure 1-32
EXECUTE PROCEDURE
EXECUTE Procedure ( )
PROCEDURE Name
p. 2-17 ,
ESQL
,
SPL
Argument
host
INTO variable
Argument
SPL
Expression
parameter p. 3-13
name =
SELECT
Statement
(singleton)
p. 1-45
I4GL FETCH
ESQL
Figure 1-33
FETCH
FIRST
ESQL
LAST
USING SQL DESCRIPTOR "descriptor"
CURRENT
descriptor
RELATIVE row position E/C variable
+ DESCRIPTOR
sqlda
pointer
-
ABSOLUTE row position
I4GL FLUSH
ESQL
Figure 1-34
FLUSH
cursor
FLUSH id
ESQL
cursor
variable
I4GL FREE
ESQL
Figure 1-35
FREE
FREE cursor
id
cursor
ESQL variable
statement
id
ESQL statement
id variable
I4GL blob
variable
descriptor ,
variable
VALUE item Described
number Item Info
item
number
variable
Described
Item Info
field host = TYPE
variable
LENGTH
PRECISION
SCALE
NULLABLE
INDICATOR
NAME
DATA
ITYPE
IDATA
ILEN
GRANT
Figure 1-37
GRANT
Database-
GRANT + Level TO PUBLIC
Privileges
p. 1-34 ,
user
Table-
Level Table PUBLIC
ON Name TO
Privileges
p. 1-34 p. 2-19
View
Name
p. 2-19
Synonym
Name
p. 2-18 ,
Procedure user
EXECUTE ON Name
p. 2-17
+
WITH GRANT OPTION + AS grantor
Database-Level
Privileges
CONNECT
RESOURCE
DBA
Table-Level
Privileges
ALL
PRIVILEGES
INSERT
DELETE
SELECT
,
+
( column )
UPDATE
,
+ ( column )
REFERENCES
,
( column )
INDEX
ALTER
DB INFO
ISQL
Figure 1-38
INFO
INFO TABLES
Table
COLUMNS FOR Name
p. 2-19
INDEXES
ACCESS
PRIVILEGES
REFERENCES
STATUS
INSERT INTO
Figure 1-39
INSERT INTO
Procedure ( )
EXECUTE PROCEDURE Name ,
p. 2-17
Argument
Argument
SPL
Expression
p. 3-13
parameter
name =
SELECT
Statement
(singleton)
p. 1-45
,
VALUES Clause
I4GL variable
( name
)
ESQL
ESQL
:indicator variable
$indicator variable
NULL
Literal Number
p. 2-16
Quoted String
p. 2-17
USER p. 2-10
+
Literal DATETIME
p. 2-15
Literal INTERVAL
p. 2-16
TODAY p. 2-10
CURRENT p. 2-10
OL
SITENAME p. 2-10
DBSERVERNAME p. 2-10
ISQL
Figure 1-40
LOAD FROM
Table
INSERT INTO Name
p. 2-19
,
Synonym
Name ( column )
p. 2-18
View
Name
p. 2-19
I4GL insert
variable
+ LOCK TABLE
Figure 1-41
LOCK TABLE
Table
LOCK TABLE Name IN SHARE MODE
p. 2-19
EXCLUSIVE
Synonym
Name
p. 2-18
I4GL OPEN
ESQL
Figure 1-42
OPEN
cursor
OPEN id
ESQL ,
cursor USING variable name
variable
ESQL
DESCRIPTOR sqlda
pointer
DB OUTPUT TO
ISQL
Figure 1-43
OUTPUT TO
SELECT
OUTPUT TO filename Statement
p. 1-45
WITHOUT
PIPE program HEADINGS
I4GL PREPARE
ESQL
Figure 1-44
PREPARE
statement Quoted
PREPARE id FROM String
p. 2-17
ESQL
statement variable
id variable name
I4GL PUT
ESQL
Figure 1-45
PUT
cursor
PUT id
ESQL ,
ESQL
descriptor
E/C variable
sqlda
DESCRIPTOR pointer
SE RECOVER TABLE
+
Figure 1-46
RECOVER TABLE
Table
RECOVER TABLE Name
p. 2-19
+ RENAME COLUMN
Figure 1-47
RENAME COLUMN
Table
RENAME COLUMN Name .old column TO new column
p. 2-19
owner.
+ RENAME TABLE
Figure 1-48
RENAME TABLE
owner.
SE REPAIR TABLE
DB
ISQL
Figure 1-49
REPAIR TABLE
Table
REPAIR TABLE Name
p. 2-19
+ REVOKE
Figure 1-50
REVOKE
Table- Table
REVOKE Level ON Name FROM PUBLIC
Privileges p. 2-19 ,
View user
Name
p. 2-19
Synonym
Name
p. 2-18
Procedure
EXECUTE ON Name
p. 2-17
Database-
Level
Privileges
Table-Level
Privileges
ALL
PRIVILEGES
INSERT
DELETE
SELECT
UPDATE
INDEX
ALTER
REFERENCES
REVOKE
Figure 1-50 (continued)
REVOKE
Database-Level
Privileges
CONNECT
RESOURCE
DBA
ROLLBACK WORK
Figure 1-51
ROLLBACK WORK
ROLLBACK WORK
SE ROLLFORWARD DATABASE
+
Figure 1-52
ROLLFORWARD DATABASE
ROLLFORWARD Database
DATABASE Name
p. 2-6
SELECT
Figure 1-53
SELECT
UNION
UNION ALL
Select FROM
SELECT List Clause
p. 1-46 I4GL p. 1-47
ESQL
SPL
INTO
Clause
p. 1-46
+
ORDER BY INTO TEMP
Clause Clause
p. 1-49 p. 1-49
SELECT Clause
Select
SELECT List
p. 1-46
Select List
,
Expression
p. 2-9
ALL display
label
DISTINCT AS
+
UNIQUE
*
Table
Name .
p. 2-19
View
Name .
p. 2-19
Synonym
Name .
p. 2-18
,
INTO Clause
INTO data variable
ESQL
+ : indicator variable
FROM Clause
Table
FROM Name
p. 2-19 Additional
table , Tables
View alias p. 1-47
Name AS
p. 2-19
Synonym
Name
p. 2-18
Additional Tables
,
Table
Name
p. 2-19
table
View alias
+
Name AS
p. 2-19
Synonym
Name
p. 2-18
Table
OUTER Name
p. 2-19
table
View alias
Name AS
p. 2-19
Synonym
Name
p. 2-18
Table
OUTER ( Name )
p. 2-19
table , Additional
View alias Tables
Name
p. 2-19 AS
Synonym
Name
p. 2-18
AND
WHERE Clause
WHERE Condition
p. 2-3
Join
p. 1-48
Join
column Relational column
. name Operator .
name
p. 2-18
Table Table
Name Name
p. 2-19 p. 2-19
alias alias
View View
Name Name
p. 2-19 p. 2-19
Synonym Synonym
Name Name
p. 2-18 p. 2-18
,
GROUP BY Clause
GROUP BY column
name
Table .
Name
p. 2-19
View
Name .
p. 2-19
Synonym
Name .
p. 2-18
+ select
number
HAVING Clause
HAVING Condition
p. 2-3
,
ORDER BY Clause
column
ORDER BY name
Table . ASC
Name
p. 2-19 DESC
View
Name .
p. 2-19
Synonym
Name .
p. 2-18
select
number
display
label
WITH NO LOG
OL SET CONSTRAINTS
+
Figure 1-54
SET CONSTRAINTS
SET ALL
CONSTRAINTS IMMEDIATE
, DEFERRED
Constraint Name
p. 2-5
Figure 1-55
SET DEBUG FILE TO
Item Descriptor
Information
TYPE = literal integer
LENGTH integer-host
variable
PRECISION
SCALE
NULLABLE
INDICATOR
= Literal Number
DATA p. 2-16
ITYPE Literal DATETIME
IDATA p. 2-15
ILEN Literal INTERVAL
NAME p. 2-16
Quoted String
p. 2-17
data variable
+ SET EXPLAIN
Figure 1-57
SET EXPLAIN
SET EXPLAIN
OFF
ON
OL SET ISOLATION TO
+
Figure 1-58
SET ISOLATION TO
COMMITTED READ
CURSOR STABILITY
REPEATABLE READ
NOT WAIT
OL SET
+
Figure 1-60
SET
SET LOG
BUFFERED
+ SET OPTIMIZATION
Figure 1-61
SET OPTIMIZATION
SET
OPTIMIZATION
HIGH
LOW
SE START DATABASE
+
Figure 1-62
START DATABASE
Database
START DATABASE Name WITH LOG IN "pathname"
p. 2-6
MODE ANSI
I4GL UNLOAD TO
DB
ISQL
Figure 1-63
UNLOAD TO
SELECT
UNLOAD TO " filename " statement
I4GL p. 1-45
DELIMITER " delimiter "
filename
variable I4GL
delimiter
variable
+ UNLOCK TABLE
Figure 1-64
UNLOCK TABLE
Table
UNLOCK TABLE Name
p. 2-19
Synonym
Name
p. 2-18
UPDATE
Figure 1-65
UPDATE
Table
UPDATE Name SET SET Clause
p. 2-19
WHERE Condition
View p. 2-3
Name I4GL
p. 2-19
ESQL
Synonym cursor
Name CURRENT OF name
p. 2-18
SET Clause
,
column
name = Expression
(Subset)
p. 2-9
SELECT
Statement
(Subset)
p. 1-45
,
, ,
column
( name ) = ( Expression )
(Subset)
* p. 2-9
I4GL
Table SELECT
Name .* ( Statement )
p. 2-19 (Subset)
p. 1-45
View I4GL
Name .*
p. 2-19 record .*
variable
Synonym
Name .*
p. 2-18
+ UPDATE STATISTICS
Figure 1-66
UPDATE STATISTICS
UPDATE
STATISTICS
FOR TABLE
Table
Name
p. 2-19
Synonym
Name
p. 2-18
FOR PROCEDURE
Procedure
Name
p. 2-17
I4GL WHENEVER
ESQL
Figure 1-67
WHENEVER
+ GOTO :label
+
SQLWARNING
ANY
SQL Segments
2
Condition . . . . . . . . . . . . . . . . . . . . . . 2-3
Constraint Name . . . . . . . . . . . . . . . . . . . 2-5
Database Name . . . . . . . . . . . . . . . . . . . . 2-6
Data Type . . . . . . . . . . . . . . . . . . . . . . 2-7
DATETIME Field Qualifier . . . . . . . . . . . . . . . . 2-8
Expression . . . . . . . . . . . . . . . . . . . . . . 2-9
Identifier . . . . . . . . . . . . . . . . . . . . . . 2-12
Index Name . . . . . . . . . . . . . . . . . . . . . 2-13
INTERNAL Field Qualifer . . . . . . . . . . . . . . . . 2-14
Literal DATETIME . . . . . . . . . . . . . . . . . . . 2-15
Literal INTERVALS. . . . . . . . . . . . . . . . . . . 2-16
Literal Number . . . . . . . . . . . . . . . . . . . . 2-16
Procedure Name. . . . . . . . . . . . . . . . . . . . 2-17
Quoted String . . . . . . . . . . . . . . . . . . . . 2-17
Relational Operator . . . . . . . . . . . . . . . . . . 2-18
Synonym Name . . . . . . . . . . . . . . . . . . . . 2-18
Table Name . . . . . . . . . . . . . . . . . . . . . 2-19
View Name . . . . . . . . . . . . . . . . . . . . . 2-19
2-2 IBM Informix SQL Quick Syntax Guide
Condition
Figure 2-1
Condition
AND
OR
Condition Comparison
Condition
p. 2-4
NOT
IN
Subquery
p. 2-5
EXISTS
Subquery
p. 2-5
ALL/ANY/SOME
Subquery
p. 2-5
Comparison
Condition
+ Expression ( Literal )
p. 2-9 IN Number
p. 2-16
NOT
Literal
Datetime
p. 2-15
Table Literal
Name . Interval
p. 2-19 p. 2-16
View Quoted
Name . String
p. 2-19 p. 2-17
TODAY
Synonym
Name .
p. 2-18 USER
CURRENT
Datetime
Field Qualifier
Table OL p. 2-8
Name .
p. 2-19 SITENAME
View
Name . DBSERVERNAME
p. 2-19
Synonym column
Name . name IS NULL
p. 2-18
NOT
column Quoted
name LIKE String
p. 2-17
+
NOT
MATCHES
ESCAPE "char"
IN Subquery
Expression SELECT
p. 2-9 IN ( (Subset) )
p. 1-45
NOT
EXISTS Subquery
Expression SELECT
p. 2-9 EXISTS ( (Subset) )
p. 1-45
NOT
ALL/ANY/SOME
Subquery
Expression Relational SELECT
Operator ( (Subset) )
p. 2-9
p. 2-18 p. 1-45
ALL
ANY
SOME
Constraint Name
Figure 2-2
Constraint Name
Constraint Name
Identifier
p. 2-12
OL owner.
database
@server
Database Name
Figure 2-3
Database Name
Database Name
Identifier
p. 2-12
OL
OL dbserver-
@ name
"//dbservername/dbname"
I4GL
ESQL variable-name
SE "//dbservername/directory-path/dbname"
Data Type
Figure 2-4 Data Type
CHAR
Data
Type CHARACTER ( size )
(1)
+ DATE
DEC ( precision )
NUMERIC 16 , scale
FLOAT
float
DOUBLE PRECISION ( precision )
INTEGER
INT
+ INTERVAL INTERVAL Field Qualifier p. 2-14
+ MONEY
( precision )
16 ,2
, scale
+ SERIAL
(1)
(start)
+ SMALLFLOAT
REAL
SMALLINT
OL
TEXT
+
BYTE IN TABLE
blobspace
OL
VARCHAR ( maximum )
+
, reserve
,0
DATETIME
Field Qualifier
YEAR
MONTH TO YEAR
DAY TO MONTH
HOUR TO DAY
MINUTE TO HOUR
SECOND TO MINUTE
FRACTION TO SECOND
TO FRACTION
(3)
(digit)
Expression
Figure 2-6
Expression
+
-
*
/
||
Expression
Column
Expressions
p. 2-10
_
+ Constant
Expressions
p. 2-10
Function
Expressions
p. 2-11
Aggregate
Expressions
p. 2-12
variable
name
( Expression )
Column
Expressions
column
name
Table . +
Name
p. 2-19 [first, last]
alias .
ROWID
I4GL @
View
Name .
p. 2-19
Synonym
Name .
p. 2-18
Constant
Expressions
Quoted String
p. 2-17
USER
OL
SITENAME
+
DBSERVERNAME
Literal Number
p. 2-16
+
TODAY
CURRENT
DATETIME Field
Qualifier
p. 2-8
Literal DATETIME p. 2-15
n UNITS datetime
unit
date/
+ DAY ( datetime )
expression
Function MONTH
Expressions
WEEKDAY
YEAR
( non-date
DATE expression )
date/
EXTEND ( datetime )
expression
, first TO last
month day year
MDY ( integer , integer , integer )
expression expression expression
I4GL variable
name
ESQL
column
name
Table Name .
p. 2-19
( integer )
HEX expression
( Expression )
ROUND p. 2-9
, digit
,0
( Expression )
TRUNC p. 2-9
, digit
,0
Aggregate
Expressions
COUNT (*)
column
AVG ( DISTINCT name )
MAX UNIQUE
Table
Name
.
MIN p. 2-19
SUM
COUNT
Expression
AVG ( (Subset) )
p. 2-9
MAX ALL
MIN
SUM
Identifier
Figure 2-7
Identifier
Identifier
letter
letter
digit
underscore
Index Name
Figure 2-8
Index Name
Index Name
Identifier
OL owner.
database ;
@ dbservername
INTERVAL
Field Qualifier
YEAR
(y-precision) TO YEAR
(4)
MONTH
(precision) TO MONTH
(2)
DAY
(precision) TO DAY
(2)
HOUR
(precision) TO HOUR
(2)
MINUTE
(precision) TO MINUTE
(2)
SECOND
(precision) TO SECOND
(2)
FRACTION TO FRACTION
(f-precision)
(3)
Literal DATETIME
Figure 2-10
Literal DATETIME
Literal DATETIME
Numeric DATETIME
DATETIME ( Date ) Field Qualifier
p. 2-8
Numeric Date
yyyy
-
mo
-
dd
space
hh
:
mi
:
ss
.
f
Literal INTERVALS
Figure 2-11
Literal INTERVALS
Literal INTERVAL
INTERVAL
INTERVAL ( Numeric Date ) Field Qualifier
p. 2-14
Literal Number
Figure 2-12
Literal Number
Literal Number
digit
+ .
-
digit
. digit E digit
Procedure Name
Figure 2-13
Procedure Name
Procedure Name
Identifier
p. 2-12
OL owner.
database ;
@ dbservername
Quoted String
Figure 2-14
Quoted String
Quoted String
" "
character
""
' '
character
"
Relational Operator
Figure 2-15
Relational Operator
Relational Operator
<
<=
>
=
>=
<>
!=
Synonym Name
Figure 2-16
Synonym Name
Synonym Name
Identifier
p. 2-12
OL owner.
database ;
@ dbservername
Table Name
Figure 2-17
Table Name
Table Name
Identifier
p. 2-12
OL
owner.
+
database :
@ dbservername
View Name
Figure 2-18
View Name
View Name
Identifier
p. 2-12
OL owner.
+
database :
@ dbservername
LCALL Procedure
Name
( ) ;
p. 2-17
, ,
procedure
Argument RETURNING variable
Argument
SPL
Expression
p. 3-13
parameter
name =
SELECT
Statement
(Subset)
p. 1-45
CONTINUE
Figure 3-2
CONTINUE
CONTINUE FOR ;
WHILE
FOREACH
DEFINE
Figure 3-3
DEFINE
,
DEFINE
GLOBAL variable SQL Data Type DEFAULT Default ;
name (Subset) Value
p. 2-7
DEFAULT
OL REFERENCES BYTE NULL
TEXT
,
variable SQL Data Type
name (Subset)
p. 2-7
OL REFERENCES BYTE
TEXT
Table Name .
LIKE p. 2-19 column
Synonym
Name
p. 2-19
View Name
p. 2-19
PROCEDURE
Default Value
Literal Number
p. 2-16
Quoted String
p. 2-17
Literal Interval
p. 2-16
Literal Datetime
p. 2-15
CURRENT
p. 2-10
DATETIME
Field
Qualifier
p. 2-8
USER
TODAY
NULL
OL
DBSERVERNAME
SITENAME
EXIT
Figure 3-4
EXIT
EXIT FOR ;
WHILE
FOREACH
FOR
Figure 3-5
FOR
FOR ,
variable Statement
name IN ( left TO right ) Block END
expression expression p. 1-16 FOR
increment
STEP expression
expression
= left TO right
expression expression
increment
STEP expression
FOREACH
Figure 3-6
FOREACH
EXECUTE Procedure
PROCEDURE Name ( )
p. 2-17 ,
variable
INTO name
,
SPL
Expression
variable (Subset)
name = p. 3-13
IF
Figure 3-7
IF
IF
IF Statement List
BEGIN Statement
Block END
p. 1-16
CALL
Statement
p. 3-3
CONTINUE
Statement
p. 3-3
EXIT
Statement
p. 3-5
FOR
Statement
p. 3-6
FOREACH
Statement
p. 3-7
IF
Statement
p. 3-8
LET
Statement
p. 3-10
RAISE EXCEPTION
Statement
p. 3-11
RETURN
Statement
p. 3-11
SYSTEM
Statement
p. 3-11
TRACE
Statement
p. 3-12
WHILE
Statement
p. 3-12
SQL Statement
LET
Figure 3-8
LET
,
LET
, ,
variable Procedure SPL
name = ( Expression ) ;
Name
p. 2-17 called p. 3-13
variable =
,
SPL
Expression
p. 3-13
ON EXCEPTION
Figure 3-9
ON EXCEPTION
ON EXCEPTION
Statement
Block END EXCEPTION
p. 1-16
, ;
IN ( error )
number
RAISE EXCEPTION
Figure 3-10
RAISE EXCEPTION
RETURN
Figure 3-11
RETURN
RETURN ;
,
SPL
Expression
p. 3-13
WITH RESUME
SYSTEM
Figure 3-12
SYSTEM
character variable
TRACE
Figure 3-13
TRACE
TRACE ON ;
OFF
PROCEDURE
SPL
Expression
WHILE
Figure 3-14
WHILE
Condition Statement
WHILE Block END WHILE
p. 2-3
p. 1-16
;
SPL Expression
Figure 3-15
SPL Expression
SPL Expression
Expression
p. 2-9
||
procedure +
variable
name -
*
/ ( SPL )
Expression
,
Procedure
Name ( SPL )
p. 2-17 Expression
called =
variable
Notices
A
IBM may not offer the products, services, or features discussed
in this document in all countries. Consult your local IBM repre-
sentative for information on the products and services currently
available in your area. Any reference to an IBM product,
program, or service is not intended to state or imply that only
that IBM product, program, or service may be used. Any
functionally equivalent product, program, or service that does
not infringe any IBM intellectual property right may be used
instead. However, it is the user’s responsibility to evaluate and
verify the operation of any non-IBM product, program, or
service.
IBM may have patents or pending patent applications covering
subject matter described in this document. The furnishing of this
document does not give you any license to these patents. You can
send license inquiries, in writing, to:
Any references in this information to non-IBM Web sites are provided for
convenience only and do not in any manner serve as an endorsement of those
Web sites. The materials at those Web sites are not part of the materials for
this IBM product and use of those Web sites is at your own risk.
IBM may use or distribute any of the information you supply in any way it
believes appropriate without incurring any obligation to you.
Licensees of this program who wish to have information about it for the
purpose of enabling: (i) the exchange of information between independently
created programs and other programs (including this one) and (ii) the mutual
use of the information which has been exchanged, should contact:
IBM Corporation
J46A/G4
555 Bailey Avenue
San Jose, CA 95141-1003
U.S.A.
The licensed program described in this information and all licensed material
available for it are provided by IBM under terms of the IBM Customer
Agreement, IBM International Program License Agreement, or any equiv-
alent agreement between us.
Each copy or any portion of these sample programs or any derivative work,
must include a copyright notice as follows:
If you are viewing this information softcopy, the photographs and color illus-
trations may not appear.
Notices A-3
Trademarks
Trademarks
AIX; DB2; DB2 Universal Database; Distributed Relational Database
Architecture; NUMA-Q; OS/2, OS/390, and OS/400; IBM Informix;
C-ISAM; Foundation.2000TM; IBM Informix 4GL; IBM Informix
DataBlade Module; Client SDKTM; CloudscapeTM; CloudsyncTM;
IBM Informix Connect; IBM Informix Driver for JDBC; Dynamic
ConnectTM; IBM Informix Dynamic Scalable ArchitectureTM (DSA);
IBM Informix Dynamic ServerTM; IBM Informix Enterprise Gateway
Manager (Enterprise Gateway Manager); IBM Informix Extended Parallel
ServerTM; [Link] ServicesTM; J/FoundationTM; MaxConnectTM; Object
TranslatorTM; Red Brick Decision ServerTM; IBM Informix SE;
IBM Informix SQL; InformiXMLTM; RedBack; SystemBuilderTM; U2TM;
UniData; UniVerse; wintegrate are trademarks or registered trademarks
of International Business Machines Corporation.
Java and all Java-based trademarks and logos are trademarks or registered
trademarks of Sun Microsystems, Inc. in the United States and other
countries.
Windows, Windows NT, and Excel are either registered trademarks or trade-
marks of Microsoft Corporation in the United States and/or other countries.
Other company, product, and service names used in this publication may be
trademarks or service marks of others.