Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
256 views

SQL Quick Syntax Guide

a guide of syntax to oracle

Uploaded by

AnkitaBansalGarg
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
256 views

SQL Quick Syntax Guide

a guide of syntax to oracle

Uploaded by

AnkitaBansalGarg
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 126

SQL Quick Syntax

Guide

Version 7.2
April 1996
Part No. 000-7880A
Published by INFORMIX® Press Informix Software, Inc.
4100 Bohannon Drive
Menlo Park, CA 94025

The following are worldwide trademarks of Informix Software, Inc., or its subsidiaries, registered in the
United States of America as indicated by an “®,” and in numerous other countries worldwide:

INFORMIX®; INFORMIX®-OnLine Dynamic Server; C-ISAM®

The following are worldwide trademarks of the indicated owners or their subsidiaries, registered in the
United States of America as indicated by an “®,” and in numerous other countries worldwide:

X/Open Company Ltd.: UNIX®; X/Open®


Adobe Systems Incorporated: PostScript®

Some of the products or services mentioned in this document are provided by companies other than Informix.
These products or services are identified by the trademark or servicemark of the appropriate companies. If you
have a question about one of these products or services, please contact the company in question directly.

Documentation Team: Diana Chase, Geeta Karmarkar, Tom Noronha

Copyright © 1981-1996 by Informix Software, Inc. All Rights Reserved.

No part of this work covered by the copyright hereon may be reproduced or used in any form or by any
means—graphic, electronic, or mechanical, including photocopying, recording, taping, or information storage
and retrieval systems—without permission of the publisher.

RESTRICTED RIGHTS LEGEND

Software and accompanying materials acquired with United States Federal Government funds or intended for
use within or for any United States federal agency are provided with “Restricted Rights” as defined in DFARS
252.227-7013(c)(1)(ii) or FAR 52.227-19.

ii SQL Quick Syntax Guide


Introduction

The following statements and segments for Version 7.2 are presented in this
guide:

■ SQL statements
■ SQL segments
■ Stored Procedure Language (SPL) statements
■ INFORMIX-OnLine/Optical statements

This guide presents the syntax diagrams for statements and segments but
does not provide any explanatory information. For complete descriptions of
SQL and SPL statements and segments, see the Informix Guide to SQL: Syntax.
For complete descriptions of INFORMIX-OnLine/Optical statements, see the
INFORMIX-OnLine/Optical User Manual. These manuals provide the follow-
ing information for each statement:

■ A brief introduction that explains the purpose of the statement


■ A syntax diagram that is identical to the syntax diagram in the
SQL Quick Syntax Guide
■ A syntax table that provides the purpose, restrictions, and syntax for
all italicized elements in a syntax diagram
■ Rules and examples of usage
■ References to related statements

Introduction 3
Syntax Conventions

Syntax Conventions
This section describes conventions for syntax diagrams. Each diagram
displays the sequences of required and optional keywords, terms, and
symbols that are valid in a given statement, command line, or other
specification, as in the following diagram of the SET EXPLAIN statement.

+ SET EXPLAIN ON

OFF

Each syntax diagram begins at the upper left corner and ends at the upper
right corner with a vertical terminator. Between these points, any path that
does not stop or reverse direction describes a possible form of the statement.
(For a few diagrams, notes in the text identify path segments that are
mutually exclusive.)

Syntax elements in a path represent terms, keywords, symbols, and segments


that can appear in your statement. Except for separators in loops, which the
path approaches counterclockwise from the right, the path always
approaches elements from the left and continues to the right. Unless
otherwise noted, at least one blank character separates syntax elements.

4 INFORMIX
Elements That Can Appear on the Path

Elements That Can Appear on the Path


You might encounter one or more of the following elements on a path.

Element Description

KEYWORD A word in UPPERCASE characters is a keyword. You


must spell the word exactly as shown; however, you
can use either uppercase or lowercase characters.

(.,;@+*-/) Punctuation and other non-alphanumeric characters


are literal symbols that you must enter exactly as
shown.

' ' Single quotes are literal symbols that you must enter
as shown.

variable A word in italics represents a value that you must


supply. A table immediately following the diagram
explains the value.

ADD A term shown in a rectangle represents a subdiagram


Clause on the same page (if no page number is supplied) or a
p. 1-14 specified page, as if the subdiagram were spliced into
the diagram at this point. The same subdiagram can be
ADD Clause represented by rectangles of different shapes, as in
these symbols for the ADD Clause subdiagram.

This reference represents a statement described in the


CREATE OPTICAL
CLUSTER INFORMIX-OnLine/Optical User Manual. Imagine
Statement that the statement is spliced into the diagram at this
see INFORMIX- point.
OnLine/Optical
User Manual

OL An icon is a warning that this path is valid only for


some products, or only under certain conditions.
Characters on the icons indicate what products or
conditions support the path.

These icons might appear in a syntax diagram:

OL This path is valid only for


INFORMIX-OnLine Dynamic Server.

SE This path is valid only for INFORMIX-SE.


(1 of 3)

Introduction 5
Elements That Can Appear on the Path

Element Description
D/B This path is valid only for DB-Access.
ESQL This path is valid only for SQL state-
ments in INFORMIX-ESQL/C and
INFORMIX-ESQL/COBOL.
E/C This path is valid only for
INFORMIX-ESQL/C.
E/CO This path is valid only for
INFORMIX-ESQL/COBOL.
SPL This path is valid only for only if you are
using Informix Stored Procedure
Language (SPL).
OP This path is valid only for
INFORMIX-OnLine/Optical.

+ This path is an Informix extension to


ANSI SQL-92 entry-level standard SQL. If
you initiate Informix extension checking
and include this syntax branch, you
receive a warning. If you have set the
DBANSIWARN environment variable at
compile time, or have used the -ansi
compile flag, you receive warnings at
compile time. If you have DBANSIWARN
set at runtime, or if you compiled with
the -ansi flag, warning flags are set in the
sqlwarn structure.

GLS This path is valid only only if your


database or application is GLS compliant.

ALL A shaded option is the default. If you do not specify


any of the available options, this option is in effect by
default.

Syntax that is enclosed between a pair of arrows is


a subdiagram.
(2 of 3)

6 INFORMIX
Elements That Can Appear on the Path

Element Description

The vertical line is a terminator. This symbol only


appears at the right, indicating that the syntax
diagram is complete.

IS NULL A branch below the main path indicates an optional


path. (Any term on the main path is required, unless
NOT a branch can circumvent it.)
NOT FOUND A set of multiple branches indicates that a choice
among more than two different paths is available.
ERROR

WARNING
, A loop indicates a path that you can repeat.
Punctuation along the top of the loop indicates the
variable separator symbol for list items, as in this example. If no
symbol appears, a blank space is the separator,
statement

, A gate ( 3 ) on a path indicates that you can only use


that path the indicated number of times, even if it is
3 size part of a larger loop. Here you can specify size no more
than three times within this statement segment.
(3 of 3)

Introduction 7
How to Read a Syntax Diagram

How to Read a Syntax Diagram


Figure 1 shows a syntax diagram that uses most of the path elements that are
listed in the previous table.
Figure 1
Elements of a Syntax Diagram

Main diagram

CREATE DATABASE database name

OL IN dbspace OL OL Log Clause

Subdiagram SE SE Log Clause

OL Log Clause

WITH LOG

BUFFERED

LOG MODE ANSI

SE Log Clause

WITH LOG IN 'pathname'

MODE ANSI

To use this diagram to construct a statement, start at the top left with the
keywords CREATE DATABASE. Then follow the diagram to the right,
proceeding through the options that you want.

8 INFORMIX
Sample-Code Conventions

To read the example syntax diagram

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.
5. If desired, you can specify logging. Here, you are constrained by the
database server with which you are working:
❑ If you are using INFORMIX-OnLine Dynamic Server, 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 INFORMIX-SE, go to the subdiagram named SE
Log Clause. Follow the subdiagram by typing the keywords
WITH LOG IN, typing a quote, supplying a pathname, and clos-
ing 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.

Sample-Code Conventions
Examples of SQL code occur throughout this manual. Except where noted,
the code is not specific to any single Informix application development tool.
If only SQL statements are listed in the example, they are not delimited by
semicolons. To use this SQL code for a specific product, you must apply the
syntax rules for that product. For example, if you are using the Query-
language option of DB-Access, you must delimit multiple statements with
semicolons. If you are using an SQL API, you must use EXEC SQL and a
semicolon (or other appropriate delimiters) at the start and end of each
statement, respectively.

Introduction 9
Section
SQL Statements
ALLOCATE DESCRIPTOR

ALLOCATE DESCRIPTOR

+
ALLOCATE ' descriptor '
ESQL DESCRIPTOR
descriptor WITH MAX occurrences
variable
occurrences
variable

ALTER FRAGMENT

OL ATTACH
ALTER FRAGMENT ON TABLE surviving table
+ Clause
p. 14

DETACH
Clause
p. 14
INDEX surviving index

INIT
Clause
p. 14

ADD
Clause
p. 16
DROP
Clause
p. 16

MODIFY
Clause
p. 16

SQL Statements 13
ALTER FRAGMENT

ATTACH Clause

ATTACH
Clause
,
ATTACH consumed table

AS frag-expression
,
BEFORE dbspace
surviving table 1
AFTER
AS frag-expression AS REMAINDER

DETACH Clause

DETACH
Clause

DETACH dbspace-name new table

INIT Clause

INIT
Clause

INIT FRAGMENT
BY
Clause
for Tables
WITH ROWIDS
FRAGMENT
BY
Clause
for Indexes
IN dbspace

14 SQL Quick Syntax Guide


ALTER FRAGMENT

FRAGMENT BY Clause for Tables

FRAGMENT
BY
Clause
for Tables
,
FRAGMENT BY ROUND ROBIN IN dbspace , dbspace

,
EXPRESSION frag-expression , frag-expression
IN dbspace IN dbspace

REMAINDER IN
, remainder dbspace

FRAGMENT BY Clause for Indexes

FRAGMENT
BY
Clause
for Indexes
,
FRAGMENT BY EXPRESSION frag-expression , frag-expression
IN dbspace IN dbspace

REMAINDER IN
, remainder dbspace

SQL Statements 15
ALTER FRAGMENT

ADD Clause

ADD
Clause

ADD new dbspace

frag-expression IN new dbspace

BEFORE existing dbspace

AFTER

REMAINDER IN new dbspace

DROP Clause

DROP
Clause

DROP dbspace-name

MODIFY Clause

MODIFY
Clause
,
MODIFY mod-dbspace TO frag-expression IN new-dbspace

1 REMAINDER IN new-dbspace

16 SQL Quick Syntax Guide


ALTER INDEX

ALTER INDEX

+ ALTER INDEX Index Name TO CLUSTER


p. 104
NOT

ALTER TABLE

,
+ ALTER TABLE Table Name ADD Clause
p. 108 p. 18

Synonym DROP Clause


Name p. 21
p. 108
MODIFY Clause
p. 21

ADD CONSTRAINT
Clause p. 22

DROP CONSTRAINT
Clause p. 23
OL

1 MODIFY NEXT SIZE


Clause p. 23

1 LOCK MODE
Clause p. 23
1 ADD ROWIDS

DROP ROWIDS

SQL Statements 17
ALTER TABLE

ADD Clause

ADD Clause

ADD Add Column


Clause

,
( Add Column )
Clause

Add Column Clause

Add Column
Clause

new
column Data Type
name p. 94
DEFAULT
Clause column
New Column
p. 19 BEFORE name
Constraint
Definition
p. 19

18 SQL Quick Syntax Guide


ALTER TABLE

DEFAULT Clause

DEFAULT
Clause
DEFAULT literal

NULL

CURRENT
p. 97
DATETIME
Field Qualifier
p. 95
USER
p. 97

TODAY
p. 97

SITENAME
p. 97

DBSERVERNAME
p. 97

New Column Constraint Definition

New Column
Constraint
Definition

UNIQUE
+ +
NOT
NULL
+ DISTINCT Constraint-
Mode
PRIMARY Definitions
Constraint- KEY
Mode p. 20
Definitions
p. 20 REFERENCES
Clause
p. 20

CHECK
Clause
p. 20

SQL Statements 19
ALTER TABLE

Constraint-Mode Definitions

Constraint-Mode
Definitions

Constraint
CONSTRAINT Name DISABLED
p. 93
ENABLED
FILTERING
WITHOUT
ERROR
WITH
ERROR

REFERENCES Clause

REFERENCES
Clause

REFERENCES table name


OL
,
+
( column ) ON DELETE CASCADE
name

CHECK Clause

CHECK
Clause

CHECK ( Condition
p. 89
)

20 SQL Quick Syntax Guide


ALTER TABLE

DROP Clause

DROP
Clause

DROP column name


,
( column name )

MODIFY Clause

MODIFY
Clause

MODIFY Modify Column


Clause
,
( Modify Column )
Clause

Modify Column Clause

Modify Column
Clause

column Data Type


name p. 94 ,
DEFAULT
Clause
p. 19 New Column
Constraint
Definition
p. 19

SQL Statements 21
ALTER TABLE

ADD CONSTRAINT Clause

ADD CONSTRAINT
Clause

Table-Level
ADD CONSTRAINT Constraint
Definition

,
( Table-Level )
Constraint
Definition

Table-Level Constraint Definition

Table-Level
Constraint Definition ,
UNIQUE ( column
name
)
+
+
DISTINCT Constraint-Mode
Definitions
p. 20
PRIMARY
KEY ,
REFERENCES
FOREIGN KEY ( column
name
) Clause
p. 20

CHECK
Clause
p. 20

22 SQL Quick Syntax Guide


ALTER TABLE

DROP CONSTRAINT Clause

DROP CONSTRAINT
Clause
Constraint
DROP CONSTRAINT Name
p. 93
,
Constraint
( Name )
p. 93

MODIFY NEXT SIZE Clause

MODIFY NEXT SIZE


Clause
MODIFY NEXT SIZE kbytes

LOCK MODE Clause

LOCK MODE
Clause

LOCK MODE ( PAGE )


ROW

SQL Statements 23
BEGIN WORK

BEGIN WORK

+ BEGIN WORK

CHECK TABLE

SE
Table
DB CHECK TABLE Name
+ p. 108

CLOSE

ESQL CLOSE cursor id

CLOSE DATABASE

+ CLOSE DATABASE

COMMIT WORK

COMMIT WORK

24 SQL Quick Syntax Guide


CONNECT

CONNECT

+ CONNECT TO Database
Environment
ESQL ESQL

AS ' connection
name ' USER
Clause
conn_nm p. 26
AS variable
DEFAULT

ESQL

WITH CONCURRENT TRANSACTION

Database Environment

Database
Environment

'dbname'

'@dbservername'
'dbname@dbservername'
ESQL db_env variable

SE

'pathname/dbname'
'pathname/dbname@dbservername'

SQL Statements 25
CREATE AUDIT

USER Clause

USER
Clause

USER ' user identifier ' USING auth variable


user_id
variable

CREATE AUDIT

SE Table
+
CREATE AUDIT FOR Name IN ' pathname '
p. 108

Synonym
Name
p. 108

CREATE DATABASE

+ CREATE Database
DATABASE Name
p. 93 OL IN dbspace SE SE Log Clause

OL OL Log Clause

SE LOG Clause

SE Log Clause

WITH LOG IN ' pathname '

MODE ANSI

26 SQL Quick Syntax Guide


CREATE INDEX

OL LOG Clause

OL Log Clause

WITH LOG

BUFFERED

LOG MODE ANSI

CREATE INDEX

+ CREATE INDEX Index


Definition
UNIQUE CLUSTER p. 28

DISTINCT

OL OL Object Modes
for Unique
FILLFACTOR percent Indexes
IN dbspace p. 28

FRAGMENT Object Modes


BY for Duplicate
EXPRESSION Indexes
Clause p. 29
p. 28

SQL Statements 27
CREATE INDEX

Index Definition

Index
Definition
,
Index ON table name ( column name )
Name
p. 104
ASC
Synonym
Name DESC
p. 108

FRAGMENT BY EXPRESSION Clause

FRAGMENT BY
EXPRESSION
Clause ,
FRAGMENT BY frag-expression , frag-expression
EXPRESSION IN dbspace IN dbspace REMAINDER IN
remainder
, dbspace

Object Modes for Unique Indexes

Object Modes for


Unique Indexes

DISABLED

ENABLED

FILTERING
WITHOUT
ERROR

WITH
ERROR

28 SQL Quick Syntax Guide


CREATE PROCEDURE

Object Modes for Duplicate Indexes

Object Modes for


Duplicate Indexes

DISABLED

ENABLED

CREATE PROCEDURE

Procedure
+ CREATE PROCEDURE Name ( )
p. 107 ,
DBA RETURNING
Parameter Clause
p. 30

Statement END
Block ;
p. 31 PROCEDURE ,
WITH
DOCUMENT Quoted String LISTING IN ' pathname '
p. 107

Parameter Option

Parameter

variable SQL Data Type


name (Subset)
p. 94
DEFAULT default
value
LIKE table . column
name name

REFERENCES BYTE

TEXT DEFAULT
NULL

SQL Statements 29
CREATE PROCEDURE

RETURNING Clause

RETURNING
Clause ,
RETURNING SQL Data Type
(Subset)
;
p. 94

REFERENCES BYTE

TEXT

30 SQL Quick Syntax Guide


CREATE PROCEDURE

Statement Block

Statement Block

CALL Statement
DEFINE ON p. 113
Statement EXCEPTION
p. 114 Statement CONTINUE
p. 119 Statement
p. 113

EXECUTE PROCEDURE
Statement
p. 50

EXIT Statement
p. 115

FOR Statement
p. 116

FOREACH Statement
p. 117

IF Statement
p. 117

LET Statement
p. 119

RAISE EXCEPTION
Statement
p. 119

RETURN Statement
p. 120

SYSTEM Statement
p. 120

TRACE Statement
p. 120

WHILE Statement
p. 120

Subset of SQL
Statement
see SQLS
;
Statement
BEGIN Block END

SQL Statements 31
CREATE PROCEDURE FROM

CREATE PROCEDURE FROM

ESQL
+
CREATE PROCEDURE FROM ' filename '

variable
name

CREATE ROLE

+
CREATE ROLE role name
OL

CREATE SCHEMA

CREATE SCHEMA user CREATE TABLE


DB Statement
AUTHORIZATION name
p. 33

CREATE INDEX
+ Statement
p. 27

CREATE VIEW
Statement
p. 44

CREATE SYNONYM
+ Statement
p. 33

GRANT
Statement
p. 55

CREATE TRIGGER
Statement
p. 40

CREATE OPTICAL
OP CLUSTER
Statement
p. 123

32 SQL Quick Syntax Guide


CREATE SYNONYM

CREATE SYNONYM

+ CREATE SYNONYM Synonym FOR Table Name


Name p. 108
PUBLIC p. 108
View Name
p. 109
PRIVATE

CREATE TABLE
,
CREATE TABLE Table ( Column )
Name
p. 108
Definition , OL
, Table-Level
Constraint WITH
+ ROWIDS
Definition
TEMP p. 36
TABLE
Clause
p. 37 Storage
Option
p. 39

Column-Definition Option

Column
Definition
column Data Type
name p. 94
DEFAULT Column-Level
Clause Constraint
p. 34 Definition
p. 35

SQL Statements 33
CREATE TABLE

DEFAULT Clause

DEFAULT
Clause

DEFAULT literal

NULL
+

CURRENT
p. 97
DATETIME
Field Qualifier
p. 95
USER
p. 97
+
TODAY
p. 97
OL

SITENAME
+ p. 97

DBSERVERNAME
p. 97

34 SQL Quick Syntax Guide


CREATE TABLE

Column-Level Constraint-Definition Option

Column-Level
Constraint
Definition

UNIQUE
NOT + +
NULL
+ DISTINCT Constraint-
Mode
PRIMARY Definitions
Constraint- KEY
Mode
Definitions
REFERENCES
Clause
p. 36

CHECK
Clause
p. 36

Constraint-Mode Definitions

Constraint-Mode
Definitions

DISABLED
Constraint
CONSTRAINT Name ENABLED
p. 93
FILTERING
WITHOUT
ERROR
WITH
ERROR

SQL Statements 35
CREATE TABLE

REFERENCES Clause

REFERENCES
Clause

REFERENCES table
name
OL
,
+
( column ) ON DELETE CASCADE
name

CHECK Clause

CHECK
Clause

CHECK ( Condition
p. 89
)

Table-Level Constraint-Definition Option

Table-Level
Constraint Definition ,
UNIQUE ( column
name
)
+
+
DISTINCT Constraint-Mode
Definitions
p. 35
PRIMARY
KEY ,
REFERENCES
FOREIGN KEY ( column
name
) Clause

CHECK
Clause

36 SQL Quick Syntax Guide


CREATE TABLE

TEMP TABLE Clause

TEMP TABLE
Clause

,
TEMP temp
TABLE table ( Temporary
Table
)
name Column ,
Definition WITH NO LOG
, Temp Table
Table-Level
Constraint
p. 38

Temporary Table Column Definition

Temporary Table Column


Definition

column Data Type


name p. 94
DEFAULT NOT NULL Temp Table
Clause Column
p. 34 Constraint
Definition
p. 38

SQL Statements 37
CREATE TABLE

Temp Table Column Constraint Definition

Temp Table Column


Constraint Definition

UNIQUE
+

DISTINCT

PRIMARY
KEY

CHECK
Clause
p. 36

Temp Table Table-Level Constraint

Temp Table Table-Level


Constraint ,
UNIQUE ( column )
name
+

DISTINCT
PRIMARY
KEY

CHECK
Clause
p. 36

38 SQL Quick Syntax Guide


CREATE TABLE

Storage Option

Storage
Option

OL

IN dbspace Extent Option LOCK MODE


Clause
p. 40
FRAGMENT
BY
Clause

SE IN 'pathname'

FRAGMENT BY Clause

FRAGMENT
BY
Clause
,
FRAGMENT BY ROUND ROBIN IN dbspace , dbspace

,
EXPRESSION frag-expression , frag-expression
IN dbspace IN dbspace REMAINDER IN
, remainder
dbspace

Extent Option

Extent Option

first next
EXTENT SIZE kbytes NEXT SIZE kbytes

SQL Statements 39
CREATE TRIGGER

LOCK MODE Clause

LOCK MODE Clause

LOCK MODE PAGE

ROW

CREATE TRIGGER

DB
Trigger
ESQL CREATE TRIGGER Name
+ p. 41
Trigger Object
Modes
p. 43

Table Action
INSERT ON Name Clause
p. 108 p. 41

Insert Action
REFERENCING Clause
Clause Referencing
p. 42 p. 43

Table Action
DELETE ON Name Clause
p. 108 p. 41

Delete Action
REFERENCING Clause
Clause Referencing
p. 42 p. 43

UPDATE Table Action


Clause ON Name Clause
p. 41 p. 108 p. 41

Update Action
REFERENCING Clause
Clause Referencing
p. 42 p. 43

40 SQL Quick Syntax Guide


CREATE TRIGGER

Trigger Name

Trigger
Name

Identifier
p. 104
owner.

UPDATE Clause

UPDATE
Clause

UPDATE
,
OF column name

Action Clause

Action
Clause

Triggered
BEFORE Action List
p. 43 Triggered Triggered
FOR EACH AFTER
Action List Action List
ROW p. 43 p. 43

FOR EACH Triggered


Action List
ROW p. 43
Triggered
AFTER Action List
p. 43
Triggered
AFTER Action List
p. 43

SQL Statements 41
CREATE TRIGGER

Insert REFERENCING Clause

Insert
REFERENCING
Clause

REFERENCING NEW correlation name

AS

Delete REFERENCING Clause

Delete
REFERENCING
Clause

REFERENCING OLD correlation name

AS

Update REFERENCING Clause

Update
REFERENCING
Clause

REFERENCING 1 OLD correlation


name
AS

1 NEW correlation
name
AS

42 SQL Quick Syntax Guide


CREATE TRIGGER

Action Clause Referencing

Action
Clause
Referencing
FOR EACH Triggered
Action List
ROW
Triggered Triggered
BEFORE Action List AFTER Action List

Triggered Action List

Triggered
Action List
, ,
INSERT
( Statement )
p. 59
Condition
WHEN ( p. 89 ) DELETE
Statement
p. 45

UPDATE
Statement
p. 84

EXECUTE
PROCEDURE
p. 50

Trigger Object Modes

Trigger Object
Modes

DISABLED

ENABLED

SQL Statements 43
CREATE VIEW

CREATE VIEW

View SELECT
CREATE VIEW Name AS Statement
p. 109 , (Subset)
p. 69 WITH CHECK
column
( name ) OPTION

DATABASE

+
Database
DATABASE Name
p. 93
EXCLUSIVE

DEALLOCATE DESCRIPTOR

+
DEALLOCATE DESCRIPTOR 'descriptor '
ESQL
descriptor
variable

44 SQL Quick Syntax Guide


DECLARE

DECLARE

INSERT
ESQL DECLARE cursor CURSOR FOR + Statement
id (Subset)
+ p. 59
+
WITH
cursor HOLD
variable
+

+
SELECT
FOR READ ONLY
Statement
(Subset) FOR
p. 69 UPDATE
,
column
OF
SCROLL
FOR
name
CURSOR

WITH
HOLD SELECT
Statement
p. 69
statement id
+
statement id
variable
EXECUTE
PROCEDURE
Statement
p. 50

DELETE

Table
DELETE FROM Name
p. 108
WHERE Condition
View p. 89
Name
p. 109 ESQL
Synonym cursor
CURRENT OF name
Name
p. 108

SQL Statements 45
DESCRIBE

DESCRIBE
ESQL USING
+ DESCRIBE statement id
SQL DESCRIPTOR
' descriptor '
E/C descriptor
statement
id variable variable
INTO sqlda pointer

DISCONNECT

+ DISCONNECT CURRENT

ESQL

DEFAULT
ALL

' connection name '


conn_nm variable

DROP AUDIT
SE Table Name
+ DROP AUDIT FOR
p. 108

Synonym
Name
p. 108

DROP DATABASE

+ Database
DROP DATABASE Name
p. 93

46 SQL Quick Syntax Guide


DROP INDEX

DROP INDEX

+ Index
DROP INDEX Name
p. 104

DROP PROCEDURE

Procedure
+ DROP PROCEDURE Name
p. 107

DROP ROLE

+
DROP ROLE role name
OL

DROP SYNONYM

Synonym
+ DROP SYNONYM Name
p. 108

DROP TABLE

Table
+ DROP TABLE Name
p. 108
CASCADE
Synonym
Name
p. 108 RESTRICT

SQL Statements 47
DROP TRIGGER

DROP TRIGGER

DB
Trigger
ESQL DROP TRIGGER Name
+ p. 41

DROP VIEW

View
+ DROP VIEW Name
p. 109
CASCADE
Synonym
Name RESTRICT
p. 108

EXECUTE

ESQL EXECUTE statement id

statement
id variable INTO USING
Clause Clause
p. 49 p. 49

48 SQL Quick Syntax Guide


EXECUTE

USING Clause

USING
Clause ,
storage
USING variable
name
E/C
storage
+ : indicator
variable

storage
INDICATOR indicator
variable

SQL DESCRIPTOR 'storage descriptor '


E/C storage descriptor variable

DESCRIPTOR storage sqlda pointer

INTO Clause

INTO
Clause
,
output
INTO variable
name
E/C
: output
+ indicator
variable

output
INDICATOR indicator
variable

SQL DESCRIPTOR ' output descriptor '


E/C output descriptor variable

DESCRIPTOR output sqlda pointer

SQL Statements 49
EXECUTE IMMEDIATE

EXECUTE IMMEDIATE

+ Quoted
EXECUTE IMMEDIATE String
ESQL
p. 107

statement variable name

EXECUTE PROCEDURE

EXECUTE Procedure
+
PROCEDURE Name ( )
p. 107 , ESQL
SPL
,
Argument
host
INTO variable

Argument

Argument
Expression
p. 96

parameter name =
SELECT
Statement
(Singleton)
p. 69

50 SQL Quick Syntax Guide


FETCH

FETCH

,
data
ESQL FETCH cursor id INTO variable
+ cursor
variable + indicator
NEXT variable
PREVIOUS
indicator
+ INDICATOR variable
PRIOR
data structure
FIRST
LAST
CURRENT
USING SQL 'descriptor'
DESCRIPTOR
descriptor
RELATIVE row variable
position E/C

+
DESCRIPTOR sqlda
- pointer
ABSOLUTE row
position

FLUSH

ESQL cursor
FLUSH
+ id

cursor
variable

SQL Statements 51
FREE

FREE

ESQL
+ FREE cursor id

cursor
variable
statement
id
statement
id variable

GET DESCRIPTOR

+
ESQL GET DESCRIPTOR 'descriptor ' host variable = COUNT

descriptor ,
variable
item Described
VALUE Item Info
number p. 53
item
number
variable

52 SQL Quick Syntax Guide


GET DIAGNOSTICS

Described Item Info

Described
Item Info

field host = TYPE


variable
LENGTH
PRECISION
SCALE
NULLABLE
INDICATOR
NAME
DATA
ITYPE
IDATA
ILENGTH

GET DIAGNOSTICS

+ Statement
GET DIAGNOSTICS Clause
ESQL

EXCEPTION
Clause
p. 54

Statement Clause

Statement
Clause
,
st_var = MORE

NUMBER

ROW_COUNT

SQL Statements 53
GET DIAGNOSTICS

EXCEPTION Clause

EXCEPTION
Clause ,
EXCEPTION except_num ex_var = CLASS_ORIGIN

en_var
CONNECTION_ALIAS

MESSAGE_LENGTH

MESSAGE_TEXT

RETURNED_SQLSTATE

SERVER_NAME

SUBCLASS_ORIGIN

54 SQL Quick Syntax Guide


GRANT

GRANT

+ Database-Level TO
GRANT Privileges PUBLIC

,
user

' user '


OL
role name TO PUBLIC
+
,
WITH
user GRANT
OPTION
' user '

role
name

' role
name'
+ Procedure
EXECUTE ON Name
p. 107

Table Privileges
for PUBLIC
and Users
p. 56

OL Table Privileges
for Roles
+ p. 56

Database-Level Privileges

Database-Level
Privileges

CONNECT

RESOURCE

DBA

SQL Statements 55
GRANT

Table Privileges for PUBLIC and Users

Table Privileges for


PUBLIC and Users

Table- Table
Level ON Name TO PUBLIC
Privileges p. 108 ,
p. 57
View user
Name
p. 109 ' user '

Synonym
Name
p. 108

+ +
WITH GRANT OPTION AS grantor

Table Privileges for Roles

Table Privileges
for Roles

Table- Table
Level ON Name TO role name
Privileges p. 108
p. 57
View ' role name'
Name
p. 109

Synonym
Name
p. 108
AS grantor

56 SQL Quick Syntax Guide


GRANT

Table-Level Privileges

Table-Level Privileges
ALL

PRIVILEGES
,

INSERT
DELETE
SELECT
+ ,
( column )
name
UPDATE
+ ,
( column )
name
REFERENCES
,
+
( column )
name
INDEX

ALTER

SQL Statements 57
GRANT FRAGMENT

GRANT FRAGMENT
,
OL GRANT Fragment-Level
FRAGMENT Privileges ON tablename ( dbspace )
+

,
TO user

'user ' WITH GRANT AS grantor


OPTION

Fragment-Level Privileges

Fragment-Level
Privileges

ALL
,
INSERT
DELETE
UPDATE

58 SQL Quick Syntax Guide


INFO

INFO

DB
INFO TABLES
+
Table
COLUMNS FOR Name
p. 108
INDEXES
ACCESS
PRIVILEGES

REFERENCES
STATUS
OL

FRAGMENTS

INSERT

Table VALUES Clause


INSERT INTO Name p. 61
p. 108 ,
View
Name ( column
name
) SELECT
p. 109 Statement
(Subset)
Synonym p. 69
Name
p. 108
+

Procedure
EXECUTE PROCEDURE Name ( )
p. 107
,
Argument
p. 60

SQL Statements 59
INSERT

Argument

Argument
Expression
p. 96
parameter
name
=
SELECT
Statement
(Singleton)
p. 69

60 SQL Quick Syntax Guide


INSERT

VALUES Clause

VALUES Clause
,
variable
VALUES ( ESQL name )

: indicator variable
+

$ indicator variable
NULL

Literal Number
p. 107

Quoted String
p. 107

USER
p. 97
+

Literal DATETIME
p. 105

Literal INTERVAL
p. 106

TODAY p. 97

CURRENT p. 97
OL
SITENAME p. 97

DBSERVERNAME
p. 97

SQL Statements 61
LOAD

LOAD
DB
+ LOAD FROM ' filename '
DELIMITER ' delimiter '

Table
INSERT INTO Name
p. 108
,
Synonym
Name ) column )
p. 108
name
View
Name
p. 109

LOCK TABLE

Table
+ LOCK TABLE Name IN SHARE MODE
p. 108
EXCLUSIVE
Synonym
Name
p. 108

62 SQL Quick Syntax Guide


OPEN

OPEN
ESQL OPEN cursor
id
E/C
+
cursor
variable WITH REOPTIMIZATION

,
USING variable name

SQL DESCRIPTOR 'descriptor'


E/C descriptor
variable

DESCRIPTOR sqlda
pointer

OUTPUT

DB SELECT
+ OUTPUT TO filename Statement
p. 69
WITHOUT
PIPE program HEADINGS

PREPARE

ESQL statement Quoted


+ PREPARE FROM String
id
p. 107

statement statement
id variable variable
name

SQL Statements 63
PUT

PUT

ESQL cursor
+ PUT id

cursor ,
variable
variable
FROM name
+ : indicator
variable

$ indicator
variable

INDICATOR indicator
variable

USING SQL DESCRIPTOR ' descriptor '


descriptor
E/C variable
sqlda
DESCRIPTOR pointer

RECOVER TABLE

SE Table
+ RECOVER TABLE Name
p. 108

RENAME COLUMN

+ Table
RENAME COLUMN Name .old column name TO new column name
p. 108

64 SQL Quick Syntax Guide


RENAME DATABASE

RENAME DATABASE
OL
RENAME DATABASE old database name TO new database name
+

RENAME TABLE

Table
+ RENAME TABLE Name TO new table
p. 108 name

REPAIR TABLE

SE
Table
DB REPAIR TABLE Name
+ p. 108

SQL Statements 65
REVOKE

REVOKE

+ Table-Level
REVOKE Privileges ON table name FROM PUBLIC
p. 67
view name ,
synonym user
name
'user '
Procedure
EXECUTE ON Name OL
p. 107
OL role name role
name

' role '


name
Table-Level
Privileges ON table name FROM PUBLIC
p. 67
view name ,
user
synonym
name
'user '

OL

CASCADE

RESTRICT

Database-
Level FROM PUBLIC
Privileges
p. 67 ,
user

'user '

66 SQL Quick Syntax Guide


REVOKE

Table-Level Privileges

Table-Level
Privileges
ALL

PRIVILEGES

INSERT

DELETE

SELECT

UPDATE

INDEX

ALTER
REFERENCES

Database-Level Privileges

Database-Level
Privileges

CONNECT

RESOURCE

DBA

SQL Statements 67
REVOKE FRAGMENT

REVOKE FRAGMENT

OL REVOKE Fragment-Level
FRAGMENT Privileges ON tablename
+

,
FROM user
,
'user '
( dbspace )

Fragment-Level Privileges

Fragment-Level
Privileges

ALL
,
INSERT
DELETE
UPDATE

ROLLBACK WORK

ROLLBACK

WORK

68 SQL Quick Syntax Guide


ROLLFORWARD DATABASE

ROLLFORWARD DATABASE

SE Database
+ ROLLFORWARD DATABASE
Name
p. 93

SELECT
UNION

UNION ALL
Select FROM
SELECT Clause Clause
p. 70 p. 71
ESQL
SPL
INTO
Clause
p. 71

WHERE HAVING GROUP BY


Clause Clause Clause p. 73
p. 72 p. 74

ORDER BY + +
Clause p. 74 INTO TEMP
FOR READ ONLY Clause p. 74

FOR UPDATE
,
column
OF
name

SQL Statements 69
SELECT

SELECT Clause

Select ,
Clause
Select
List
ALL
DISTINCT
+
UNIQUE

Select List

Select
List
Expression
p. 96
display
label
AS

*
Table .
Name
p. 108

View .
Name
p. 109

Synonym
Name .
p. 108

70 SQL Quick Syntax Guide


SELECT

INTO Clause

INTO
Clause
,
INTO data variable

ESQL

+ : indicator
variable

$ indicator
variable

INDICATOR indicator variable

data structure

FROM Clause

FROM
Clause
Table
FROM Name
p. 108
alias , Additional
Tables
View
Name + p. 72
p. 109
AS
Synonym
Name
p. 108

SQL Statements 71
SELECT

Additional Tables

Additional
Tables
,
Table
Name
p. 108
alias
View
+ Name +
p. 109
AS
Synonym
Name
p. 108
Table
OUTER Name
p. 108
alias
View
Name AS
p. 109
Synonym
Name
p. 108

Table
OUTER ( Name )
p. 108
View alias , Additional
Name Tables
p. 109 AS
Synonym
Name
p. 108

WHERE Clause

WHERE AND
Clause
Condition
WHERE p. 89

Join
p. 73

72 SQL Quick Syntax Guide


SELECT

Join Option

Join

column Relational column


name Operator name
p. 108
Table Table
Name . Name .
p. 108 p. 108

alias . alias .
View View
Name . Name .
p. 109 p. 109

Synonym Synonym
Name . Name .
p. 108 p. 108

GROUP BY Clause

GROUP BY ,
Clause
column
GROUP BY name
Table
Name
p. 108
View
Name .
p. 109
Synonym
Name .
p. 108

alias .

+ select
number

SQL Statements 73
SELECT

HAVING Clause

HAVING
Clause

HAVING Condition
p. 89

ORDER BY Clause

ORDER BY
Clause ,
ORDER BY
column
name
Table +
Name . ASC
p. 108 [ first, last ] DESC
View
Name .
p. 109

Synonym .
Name
p. 108
alias .

select
number
display
+ label

ROWID

INTO TEMP Clause

INTO TEMP
Clause

INTO TEMP temp table name

WITH NO LOG

74 SQL Quick Syntax Guide


SET

SET

+ SET Table-Mode
Format
p. 75

List-Mode
Format
OL p. 77

Transaction-
Mode Format
p. 77

Table-Mode Format

Table-Mode Format

,
Object Modes for
CONSTRAINTS FOR table name Constraints and
Unique Indexes
INDEXES p. 76

TRIGGERS Object Modes for


Triggers and
Duplicate Indexes
p. 76

SQL Statements 75
SET

Object Modes for Constraints and Unique Indexes

Object Modes for Constraints


and Unique Indexes

DISABLED

ENABLED

FILTERING
WITHOUT
ERROR

WITH
ERROR

Object Modes for Triggers and Duplicate Indexes

Object Modes for Triggers


and Duplicate Indexes

DISABLED

ENABLED

76 SQL Quick Syntax Guide


SET

List-Mode Format

List-Mode Format

,
Object Modes for
CONSTRAINTS constraint Constraints and
name Unique Indexes
p. 76
,
Object Modes for
INDEXES index name Constraints and
Unique Indexes
p. 76

Object Modes for


Triggers and
Duplicate Indexes
p. 76
,
Object Modes for
TRIGGERS trigger name Triggers and
Duplicate Indexes
p. 76

Transaction-Mode Format

Transaction-Mode Format
,
CONSTRAINTS constraint IMMEDIATE
name
ALL DEFERRED

SQL Statements 77
SET CONNECTION

SET CONNECTION

ESQL SET CONNECTION 'connection name'


E/C
DORMANT
+
+ conn_nm variable

+ Database
Environment
p. 25

DEFAULT
E/C
+ CURRENT

SET DATASKIP
OL
+ SET DATASKIP ON
,
dbspace

OFF

DEFAULT

SET DEBUG FILE TO


+ SET DEBUG FILE TO ' filename '
variable name WITH APPEND
character
expression

78 SQL Quick Syntax Guide


SET DESCRIPTOR

SET DESCRIPTOR

+
SET DESCRIPTOR ' descriptor ' COUNT = value
ESQL
count
descriptor variable
variable ,
item Item
VALUE number Descriptor
Information
item
number
variable

Item Descriptor Information

Item
Descriptor
Information

TYPE = literal integer

LENGTH integer-host
variable
PRECISION
SCALE
NULLABLE
INDICATOR
ITYPE
ILENGTH
Literal Number
DATA = p. 107

IDATA Literal DATETIME


p. 105
Literal INTERVAL
p. 106
NAME
Quoted String
p. 107

data variable

SQL Statements 79
SET EXPLAIN

SET EXPLAIN

+ SET EXPLAIN ON

OFF

SET ISOLATION

OL
SET ISOLATION TO DIRTY READ
+
COMMITTED READ

CURSOR STABILITY

REPEATABLE READ

SET LOCK MODE TO

+ SET LOCK MODE TO WAIT


OL
seconds

NOT WAIT

SET LOG

OL
+ SET LOG

BUFFERED

80 SQL Quick Syntax Guide


SET OPTIMIZATION

SET OPTIMIZATION
+
SET OPTIMIZATION HIGH

LOW

SET PDQPRIORITY

OL
SET PDQPRIORITY DEFAULT
+

LOW

OFF

HIGH

percent-of-resources

SET ROLE

+
SET ROLE role name
OL
NULL

NONE

SET SESSION AUTHORIZATION

ESQL
OL
SET SESSION AUTHORIZATION TO 'user '

SQL Statements 81
SET TRANSACTION

SET TRANSACTION

,
SET TRANSACTION 1 READ WRITE

READ ONLY

OL

1 ISOLATION LEVEL READ COMMITTED

REPEATABLE READ

SERIALIZABLE
,
1 READ ONLY

OL

1 ISOLATION LEVEL READ UNCOMMITTED

START DATABASE

SE Database
+ START DATABASE Name WITH LOG IN ' pathname '
p. 93
MODE ANSI
WITH NO LOG

82 SQL Quick Syntax Guide


START VIOLATIONS TABLE

START VIOLATIONS TABLE

+ START VIOLATIONS TABLE FOR tablename

USING violations , diagnostics MAX ROWS numrows

STOP VIOLATIONS TABLE

+ STOP VIOLATIONS TABLE FOR tablename

UNLOAD

DB SELECT
+ UNLOAD TO 'filename' Statement
p. 69
DELIMITER 'delimiter'

UNLOCK TABLE

+ Table
UNLOCK TABLE Name
p. 108

Synonym
Name
p. 108

SQL Statements 83
UPDATE

UPDATE

Table
UPDATE Name SET SET Clause
p. 108
WHERE Condition
View p. 89
Name ESQL
p. 109
SPL
Synonym cursor
Name CURRENT OF id
p. 108

SET Clause

SET
Clause ,
column
name = Expression
(Subset)
p. 96

SELECT
( Statement )
(Subset)
p. 69
+
NULL

, ,
column
( name ) = ( Expression
(Subset)
)
p. 96
*
SELECT
( Statement )
(Subset)
p. 69
NULL

84 SQL Quick Syntax Guide


UPDATE STATISTICS

UPDATE STATISTICS

+ UPDATE STATISTICS

FOR PROCEDURE

Procedure
Name
p. 107

LOW Table DROP


FOR Name DISTRIBUTIONS
TABLE p. 108
,
column
Synonym ( name )
Name
p. 108

MEDIUM

Table
FOR Name
TABLE p. 108 RESOLUTION percent
,
column
Synonym ( name )
Name
p. 108

OL
conf
DISTRIBUTIONS ONLY
HIGH

RESOLUTION percent
Table
FOR Name
TABLE p. 108
, OL

Synonym ( column ) DISTRIBUTIONS ONLY


Name name
p. 108

SQL Statements 85
WHENEVER

WHENEVER

ESQL WHENEVER SQLERROR CONTINUE

GO TO + label
NOT FOUND
+ GOTO : label

SQLWARNING STOP

E/CO CALL function


name
E/CO
ERROR
+
PERFORM paragraph
name

86 SQL Quick Syntax Guide


Section
SQL Segments
Condition

Condition

AND

OR
Comparison
Condition
p. 90
NOT
Condition with
Subquery
p. 91

SQL Segments 89
Condition

Comparison Conditions (Boolean Expressions)

Comparison
Condition
Expression Relational Expression
p. 96 Operator p. 96
p. 108
Expression BETWEEN Expression AND Expression
p. 96 p. 96 p. 96
NOT
,
Expression Literal
+
p. 96 IN ( Number )
p. 107
NOT
Literal
DATETIME
p. 105
Literal
INTERVAL
p. 106
Quoted
String
p. 107
TODAY
Table
Name . USER
p. 108
CURRENT
View
Name . DATETIME
Field
p. 109
OL Qualifier
p. 95
Synonym
Name . SITENAME
p. 108
DBSERVERNAME
alias . column
name IS NULL

Table NOT
Name . Quoted
p. 108 LIKE String
p. 107
+
View NOT
Name .
p. 109 MATCHES
ESCAPE 'char'
Synonym
Name . column column name
p. 108 name
alias .

90 SQL Quick Syntax Guide


Condition

Condition with a Subquery

Condition
with
Subquery
IN
Subquery
p. 92

EXISTS
Subquery
p. 92

ALL/ANY/SOME
Subquery
p. 92

SQL Segments 91
Condition

IN Subquery

IN
Subquery

Expression Condition
p. 96 IN ( with )
Subquery
NOT p. 91

EXISTS Subquery

EXISTS
Subquery
Condition
EXISTS ( with )
Subquery
NOT p. 91

ALL/ANY/SOME Subquery

ALL/ANY/SOME
Subquery

Expression Relational Condition


p. 96 Operator ( with )
p. 108 Subquery
ALL p. 91
ANY
SOME

92 SQL Quick Syntax Guide


Constraint Name

Constraint Name

Identifier
p. 104
OL owner.

database : 'owner'.
@dbservername

Database Name

dbname

OL
OL
@ dbservername

' //dbservername/dbname '


ESQL variable name
SE
' //dbservername/pathname/dbname '

' /pathname/dbname@dbservername '

SQL Segments 93
Data Type

Data Type

CHAR

CHARACTER ( size )
(1)
GLS
NCHAR
+

+ DATE

DATETIME DATETIME Field Qualifier p. 95


+
DECIMAL

DEC ( precision )
NUMERIC 16 , scale
FLOAT
float
( precision )
DOUBLE PRECISION
INTEGER

INT

+ INTERVAL INTERVAL Field Qualifier p. 105

+ MONEY

( precision )
16 ,2
, scale
+ SERIAL

(1)
( start )
+ SMALLFLOAT

REAL
SMALLINT

OL INFORMIX-OnLine Dynamic Server-Specific Data Types p. 95

94 SQL Quick Syntax Guide


DATETIME Field Qualifier

INFORMIX-OnLine Dynamic Server-Specific Data Types

INFORMIX-OnLine Dynamic
Server-Specific
Data Types

+ TEXT

+ BYTE IN TABLE

blobspace
OP
family name

+ VARCHAR ( max )
, reserve
GLS
NVARCHAR ,0
+

CHARACTER VARYING ( max )


, reserve

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)

SQL Segments 95
Expression

Expression

-
*
/
||

Column
Expressions
p. 97
-
Constant
+ Expressions
p. 97

Function
Expressions
p. 98

Aggregate
Expressions
p. 103

Procedure Call
Expressions
p. 103

variable name

SPL procedure variable name

( Expression )

96 SQL Quick Syntax Guide


Expression

Column Expressions

column
name
Table . +
Name
p. 108 + [first, last ]
alias . ROWID

View
Name .
p. 109

Synonym
Name .
p. 108

Constant Expressions

Quoted
String
p. 107
USER
OL
+ SITENAME

DBSERVERNAME
Literal
Number
+ p. 107

TODAY
CURRENT
DATETIME
Field
Qualifier
p. 95
Literal
DATETIME
p. 105

Literal
INTERVAL
p. 106

n UNITS datetime
unit

SQL Segments 97
Expression

Function Expressions

Algebraic
+ Functions
p. 99
DBINFO
Function
p. 100

Exponential and
Logarithmic
Functions
p. 100
HEX
Function
p. 100
LENGTH
Function
p. 101
Time
Functions
p. 101

Trigonometric
Functions
p. 102

TRIM
Function
p. 102

98 SQL Quick Syntax Guide


Expression

Algebraic Functions

Algebraic
Functions

ABS ( num_expression )

MOD ( dividend, divisor )


POW ( base, exponent )

ROOT ( radicand )
, index
,2

ROUND ( Expression
p. 96
)
, rounding factor
,0
SQRT ( sqrt_radicand )

TRUNC ( Expression )
p. 96
, truncating factor
,0

SQL Segments 99
Expression

DBINFO Function

DBINFO Function

DBINFO ( OL 'DBSPACE' , tblspace num )


expression
'sqlca.sqlerrd1'
'sqlca.sqlerrd2'
OL
+
'sessionid'

Exponential and Logarithmic Functions

Exponential and Logarithmic Functions

EXP ( float expression )


LOGN ( float expression )
LOG10 ( float expression )

HEX Function

HEX Function
integer
HEX ( expression )

100 SQL Quick Syntax Guide


Expression

LENGTH Function

LENGTH
Functions
Quoted
+ String
LENGTH ( p. 107
)
CHAR_LENGTH SPL variable
CHARACTER_LENGTH ESQL name

OCTET_LENGTH column
name
Table
Name .
p. 108

Time Functions

Time Functions

+
DATE ( non-date )
expression

date/
DAY ( datetime )
expression
MONTH

WEEKDAY
YEAR

date/
EXTEND ( datetime )
expression
, first TO last

month day year


MDY ( integer , integer , integer )
expression expression expression

SQL Segments 101


Expression

Trigonometric Functions

Trigonometric
Functions

COS ( radian )
expression
SIN

TAN

ASIN ( numeric )
expression
ACOS
ATAN

ATAN2 ( y, x )

TRIM Function

TRIM
Function source
character
TRIM ( value )
expression
LEADING FROM
trim
character
TRAILING value
expression
BOTH
trim
character FROM
value
expression

102 SQL Quick Syntax Guide


Expression

Aggregate Expressions

COUNT (*)

AVG ( column
name
)
MAX DISTINCT
Table .
Name
MIN p. 108
UNIQUE
SUM Synonym
COUNT ( DISTINCT Name .
p. 108
+
UNIQUE
View
COUNT ( Name .
p. 109
ALL

AVG ( Expression
(Subset)
)
p. 96
MAX ALL
MIN
SUM
RANGE
STDEV
VARIANCE

Procedure Call Expressions

,
Procedure
Name ( Expression
p. 96
)
p. 107
called =
variable

SQL Segments 103


Identifier

Identifier

letter

underscore

letter

digit

underscore
Delimited
Identifier

Delimited Identifiers

Delimited
Identifier

double quote letter double quote

digit

underscore

nonalphanumeric character

Index Name

Identifier
OL owner.

database : 'owner'.
@ dbservername

104 SQL Quick Syntax Guide


INTERVAL Field Qualifier

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

Numeric DATETIME
DATETIME ( Date ) Field Qualifier
p. 106 p. 95

SQL Segments 105


Literal Interval

Numeric Date

Numeric Date

yyyy

-
mo

-
dd

space

hh
:
mi

:
ss

.
f

Literal Interval

INTERVAL
INTERVAL ( Numeric Date ) Field Qualifier
p. 105

106 SQL Quick Syntax Guide


Literal Number

Literal Number

digit
+ .
-
digit

. digit E digit
+
-

Procedure Name

Identifier
p. 104
OL owner.
+ 'owner'
database :
@ dbservername

Quoted String

' '

character
+
''
" "

character
""

SQL Segments 107


Relational Operator

Relational Operator

<
<=
>
=
>=
<>
+

!=

Synonym Name

Identifier
p. 104
OL owner.
+
'owner'.
database :
@ dbservername

Table Name

Identifier
p. 104
OL owner.
+
'owner'.
database :
@ dbservername

108 SQL Quick Syntax Guide


View Name

View Name

Identifier
p. 104
OL owner.
+
'owner'.
database :
@ dbservername

SQL Segments 109


Section III
Stored Procedure Language
Statements
CALL

CALL

Procedure
CALL Name ( ) ;
p. 107
, ,
Argument procedure
RETURNING variable

Argument

Argument
Expression
p. 96
parameter
name =
SELECT
Statement
(Subset)
p. 69

CONTINUE

CONTINUE FOR ;
WHILE

FOREACH

SPL Statements 113


DEFINE

DEFINE

,
Default
SQL Data Type Value
DEFINE GLOBAL variable
name
(Subset) DEFAULT p. 115 ;
p. 94
DEFAULT
OL REFERENCES BYTE NULL
TEXT

,
variable SQL Data Type
name (Subset)
p. 94

OL REFERENCES BYTE

TEXT

Table Name
LIKE p. 108 . column name

Synonym
Name
p. 108

View Name
p. 109

PROCEDURE

114 SQL Quick Syntax Guide


EXIT

Default Value Clause

Default
Value
Literal Number
p. 107

Quoted String
p. 107

Literal Interval
p. 106

Literal Datetime
p. 105

CURRENT
p. 90
DATETIME
Field
Qualifier
p. 95

USER
TODAY

NULL
OL

DBSERVERNAME
SITENAME

EXIT

EXIT FOR ;
WHILE
FOREACH

SPL Statements 115


FOR

FOR

,
variable Statement
left right
FOR name IN ( expression
TO
expression ) Block END
p. 31 FOR
;

STEP increment
expression
,
expression

= left
expression
TO right
expression

increment
STEP expression

116 SQL Quick Syntax Guide


FOREACH

FOREACH

SELECT...INTO Statement
FOREACH Block END
Statement
p. 71 p. 31 FOREACH

cursor
WITH HOLD ;
FOR
name
WITH HOLD

EXECUTE Procedure
PROCEDURE Name ( )
p. 107 ,
variable
INTO name

,
Expression
(Subset)
parameter p. 96
name =

IF

IF Condition THEN END IF


p. 89
IF Statement ;
List
p. 118

Condition IF Statement IF Statement


ELIF p. 89 THEN List ELSE List
p. 118 p. 118

SPL Statements 117


IF

IF Statement List

IF Statement
List
BEGIN Statement
Block END
p. 31

CALL
Statement
p. 113

CONTINUE
Statement
p. 113

EXIT
Statement
p. 115

FOR
Statement
p. 116

FOREACH
Statement
p. 117
IF
Statement
p. 117

LET
Statement
p. 119

RAISE EXCEPTION
Statement
p. 119

RETURN
Statement
p. 120

SYSTEM
Statement
p. 120

TRACE
Statement
p. 120

WHILE
Statement
p. 120

SQL Statement

118 SQL Quick Syntax Guide


LET

LET

,
, ,
variable Procedure Expression
LET name = Name ( p. 96 ) ;
p. 107 called
variable =
,
Expression
p. 96

ON EXCEPTION

Statement
ON EXCEPTION Block END EXCEPTION
p. 31
, ;
error
IN ( number )

SQL WITH RESUME


SET error
variable ISAM
, error
variable error
, data
variable

RAISE EXCEPTION
SQL
RAISE EXCEPTION error ;
, ISAM
error
error text
, variable

SPL Statements 119


RETURN

RETURN

RETURN ;
,
Expression
p. 96

WITH RESUME

SYSTEM

SYSTEM expression ;
character variable

TRACE

TRACE ON ;

OFF

PROCEDURE

Expression
p. 96

WHILE

Condition Statement
WHILE Block END WHILE
p. 89
p. 31
;

120 SQL Quick Syntax Guide


Section IV
INFORMIX-OnLine Optical
Statements
ALTER OPTICAL CLUSTER

ALTER OPTICAL CLUSTER


+
ALTER
OPTICAL cluster CLUSTERSIZE
DB name Clause
CLUSTER
ESQL
owner.

CLUSTERSIZE Clause

CLUSTERSIZE
Clause
CLUSTERSIZE

500

clustersize

CREATE OPTICAL CLUSTER

+
CREATE
OPTICAL cluster FOR ON
DB name Clause Clause
CLUSTER
ESQL p. 124 CLUSTERSIZE
owner. Clause

FOR Clause

FOR ,
Clause
Table Name
FOR p. 108 ( blob column name )

INFORMIX-OnLine/Optical Statements 123


ON Clause

ON Clause

ON ,
Clause
cluster-key
ON ( column name )

DROP OPTICAL CLUSTER

+
DROP
OPTICAL cluster
DB name
CLUSTER
ESQL
owner.

RELEASE
+
DB RELEASE 'family name' volume number
ESQL
ESQL
family-name
variable
SPL
procedure
variable
name

124 SQL Quick Syntax Guide


RESERVE

RESERVE

+
DB RESERVE 'family name' volume number
ESQL
ESQL

family-name
variable
SPL
procedure
variable
name

SET MOUNTING TIMEOUT


+

DB SET MOUNTING TIMEOUT TO WAIT


ESQL
NOT WAIT
seconds

Function Expressions

Function
Expressions
p. 98
+

DB
ESQL

DESCR (blob column name)


FAMILY (blob column name)
VOLUME (blob column name)

INFORMIX-OnLine/Optical Statements 125

You might also like