IBM®
DB2
Universal
Database™
SQL
Reference
Volume
2
Version
8.2
SC09-4845-01
���
IBM®
DB2
Universal
Database™
SQL
Reference
Volume
2
Version
8.2
SC09-4845-01
���
Before
using
this
information
and
the
product
it
supports,
be
sure
to
read
the
general
information
under
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.
You
can
order
IBM
publications
online
or
through
your
local
IBM
representative.
v
To
order
publications
online,
go
to
the
IBM
Publications
Center
at
www.ibm.com/shop/publications/order
v
To
find
your
local
IBM
representative,
go
to
the
IBM
Directory
of
Worldwide
Contacts
at
www.ibm.com/planetwide
To
order
DB2
publications
from
DB2
Marketing
and
Sales
in
the
United
States
or
Canada,
call
1-800-IBM-4YOU
(426-4968).
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
1993
-
2004.
All
rights
reserved.
US
Government
Users
Restricted
Rights
–
Use,
duplication
or
disclosure
restricted
by
GSA
ADP
Schedule
Contract
with
IBM
Corp.
http://www.ibm.com/shop/publications/orderhttp://www.ibm.com/planetwide
Contents
About
this
book
.
.
.
.
.
.
.
.
.
.
. v
Who
should
use
this
book
.
.
.
.
.
.
.
.
.
. v
How
this
book
is
structured
.
.
.
.
.
.
.
.
. v
A
brief
overview
of
Volume
1
.
.
.
.
.
.
. v
How
to
read
the
syntax
diagrams
.
.
.
.
.
.
. vi
Common
syntax
elements
.
.
.
.
.
.
.
.
. viii
Function
designator
.
.
.
.
.
.
.
.
.
. viii
Method
designator
.
.
.
.
.
.
.
.
.
.
. ix
Procedure
designator
.
.
.
.
.
.
.
.
.
. xi
Conventions
used
in
this
manual
.
.
.
.
.
.
. xii
Error
conditions
.
.
.
.
.
.
.
.
.
.
.
. xii
Highlighting
conventions
.
.
.
.
.
.
.
.
. xii
Related
documentation
.
.
.
.
.
.
.
.
.
. xiii
Statements
.
.
.
.
.
.
.
.
.
.
.
.
. 1
Supported
SQL
statements
.
.
.
.
.
.
.
.
.
. 1
How
SQL
statements
are
invoked
.
.
.
.
.
.
. 6
Embedding
a
statement
in
an
application
program
6
Dynamic
preparation
and
execution
.
.
.
.
. 7
Static
invocation
of
a
select-statement
.
.
.
.
. 7
Dynamic
invocation
of
a
select-statement
.
.
.
. 7
Interactive
invocation
.
.
.
.
.
.
.
.
.
. 8
SQL
use
with
other
host
systems
.
.
.
.
.
. 8
SQL
return
codes
.
.
.
.
.
.
.
.
.
.
.
. 8
SQL
comments
.
.
.
.
.
.
.
.
.
.
.
. 9
About
SQL
control
statements
.
.
.
.
.
.
.
. 10
ALLOCATE
CURSOR
.
.
.
.
.
.
.
.
.
.
. 11
ALTER
BUFFERPOOL
.
.
.
.
.
.
.
.
.
.
. 13
ALTER
DATABASE
PARTITION
GROUP
.
.
.
. 15
ALTER
FUNCTION
.
.
.
.
.
.
.
.
.
.
. 18
ALTER
METHOD
.
.
.
.
.
.
.
.
.
.
.
. 21
ALTER
NICKNAME
.
.
.
.
.
.
.
.
.
.
. 23
ALTER
PROCEDURE
.
.
.
.
.
.
.
.
.
.
. 30
ALTER
SEQUENCE
.
.
.
.
.
.
.
.
.
.
. 33
ALTER
SERVER
.
.
.
.
.
.
.
.
.
.
.
.
. 37
ALTER
TABLE
.
.
.
.
.
.
.
.
.
.
.
.
. 40
ALTER
TABLESPACE
.
.
.
.
.
.
.
.
.
.
. 72
ALTER
TYPE
(Structured)
.
.
.
.
.
.
.
.
. 79
ALTER
USER
MAPPING
.
.
.
.
.
.
.
.
.
. 86
ALTER
VIEW
.
.
.
.
.
.
.
.
.
.
.
.
.
. 88
ALTER
WRAPPER
.
.
.
.
.
.
.
.
.
.
.
. 90
ASSOCIATE
LOCATORS
.
.
.
.
.
.
.
.
.
. 92
BEGIN
DECLARE
SECTION
.
.
.
.
.
.
.
. 94
CALL
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 96
CASE
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 101
CLOSE
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 104
COMMENT
.
.
.
.
.
.
.
.
.
.
.
.
.
. 106
COMMIT
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 116
Compound
SQL
(Dynamic)
.
.
.
.
.
.
.
.
. 118
Compound
SQL
(Embedded)
.
.
.
.
.
.
.
. 123
Compound
SQL
(Procedure)
.
.
.
.
.
.
.
. 127
CONNECT
(Type
1)
.
.
.
.
.
.
.
.
.
.
. 135
CONNECT
(Type
2)
.
.
.
.
.
.
.
.
.
.
. 142
CREATE
ALIAS
.
.
.
.
.
.
.
.
.
.
.
. 149
CREATE
BUFFERPOOL
.
.
.
.
.
.
.
.
.
. 152
CREATE
DATABASE
PARTITION
GROUP
.
.
. 156
CREATE
DISTINCT
TYPE
.
.
.
.
.
.
.
.
. 158
CREATE
EVENT
MONITOR
.
.
.
.
.
.
.
. 164
CREATE
FUNCTION
.
.
.
.
.
.
.
.
.
.
. 180
CREATE
FUNCTION
(External
Scalar)
.
.
.
.
. 181
CREATE
FUNCTION
(External
Table)
.
.
.
.
. 204
CREATE
FUNCTION
(OLE
DB
External
Table)
.
. 221
CREATE
FUNCTION
(Sourced
or
Template)
.
.
. 228
CREATE
FUNCTION
(SQL
Scalar,
Table,
or
Row)
238
CREATE
FUNCTION
MAPPING
.
.
.
.
.
.
. 247
CREATE
INDEX
.
.
.
.
.
.
.
.
.
.
.
. 252
CREATE
INDEX
EXTENSION
.
.
.
.
.
.
.
. 261
CREATE
METHOD
.
.
.
.
.
.
.
.
.
.
. 267
CREATE
NICKNAME
.
.
.
.
.
.
.
.
.
. 273
CREATE
PROCEDURE
.
.
.
.
.
.
.
.
.
. 285
CREATE
PROCEDURE
(External)
.
.
.
.
.
. 286
CREATE
PROCEDURE
(SQL)
.
.
.
.
.
.
.
. 299
CREATE
SCHEMA
.
.
.
.
.
.
.
.
.
.
. 305
CREATE
SEQUENCE
.
.
.
.
.
.
.
.
.
.
. 308
CREATE
SERVER
.
.
.
.
.
.
.
.
.
.
.
. 312
CREATE
TABLE
.
.
.
.
.
.
.
.
.
.
.
. 316
CREATE
TABLESPACE
.
.
.
.
.
.
.
.
.
. 374
CREATE
TRANSFORM
.
.
.
.
.
.
.
.
.
. 383
CREATE
TRIGGER
.
.
.
.
.
.
.
.
.
.
. 390
CREATE
TYPE
(Structured)
.
.
.
.
.
.
.
. 401
CREATE
TYPE
MAPPING
.
.
.
.
.
.
.
.
. 425
CREATE
USER
MAPPING
.
.
.
.
.
.
.
.
. 430
CREATE
VIEW
.
.
.
.
.
.
.
.
.
.
.
.
. 432
CREATE
WRAPPER
.
.
.
.
.
.
.
.
.
.
. 446
DECLARE
CURSOR
.
.
.
.
.
.
.
.
.
.
. 448
DECLARE
GLOBAL
TEMPORARY
TABLE
.
.
. 454
DELETE
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 462
DESCRIBE
.
.
.
.
.
.
.
.
.
.
.
.
.
. 469
DISCONNECT
.
.
.
.
.
.
.
.
.
.
.
.
. 473
DROP
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 476
END
DECLARE
SECTION
.
.
.
.
.
.
.
.
. 500
EXECUTE
.
.
.
.
.
.
.
.
.
.
.
.
.
. 501
EXECUTE
IMMEDIATE
.
.
.
.
.
.
.
.
.
. 507
EXPLAIN
.
.
.
.
.
.
.
.
.
.
.
.
.
. 510
FETCH
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 515
FLUSH
EVENT
MONITOR
.
.
.
.
.
.
.
.
. 518
FLUSH
PACKAGE
CACHE
.
.
.
.
.
.
.
. 519
FOR
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 520
FREE
LOCATOR
.
.
.
.
.
.
.
.
.
.
.
. 523
GET
DIAGNOSTICS
.
.
.
.
.
.
.
.
.
.
. 524
GOTO
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 527
GRANT
(Database
Authorities)
.
.
.
.
.
.
. 529
GRANT
(Index
Privileges)
.
.
.
.
.
.
.
.
. 533
GRANT
(Package
Privileges)
.
.
.
.
.
.
.
. 535
GRANT
(Routine
Privileges)
.
.
.
.
.
.
.
. 538
GRANT
(Schema
Privileges)
.
.
.
.
.
.
.
. 542
GRANT
(Sequence
Privileges)
.
.
.
.
.
.
.
. 545
GRANT
(Server
Privileges)
.
.
.
.
.
.
.
.
. 547
GRANT
(Table
Space
Privileges)
.
.
.
.
.
.
. 549
GRANT
(Table,
View,
or
Nickname
Privileges)
.
. 551
IF
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 558
©
Copyright
IBM
Corp.
1993
-
2004
iii
INCLUDE
.
.
.
.
.
.
.
.
.
.
.
.
.
. 560
INSERT
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 562
ITERATE
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 571
LEAVE
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 572
LOCK
TABLE
.
.
.
.
.
.
.
.
.
.
.
.
. 574
LOOP
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 576
MERGE
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 578
OPEN
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 587
PREPARE
.
.
.
.
.
.
.
.
.
.
.
.
.
. 592
REFRESH
TABLE
.
.
.
.
.
.
.
.
.
.
.
. 601
RELEASE
(Connection)
.
.
.
.
.
.
.
.
.
. 603
RELEASE
SAVEPOINT
.
.
.
.
.
.
.
.
.
. 605
RENAME
.
.
.
.
.
.
.
.
.
.
.
.
.
. 606
RENAME
TABLESPACE
.
.
.
.
.
.
.
.
.
. 608
REPEAT
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 609
RESIGNAL
.
.
.
.
.
.
.
.
.
.
.
.
.
. 611
RETURN
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 613
REVOKE
(Database
Authorities)
.
.
.
.
.
.
. 615
REVOKE
(Index
Privileges)
.
.
.
.
.
.
.
.
. 619
REVOKE
(Package
Privileges)
.
.
.
.
.
.
.
. 621
REVOKE
(Routine
Privileges)
.
.
.
.
.
.
.
. 624
REVOKE
(Schema
Privileges)
.
.
.
.
.
.
.
. 627
REVOKE
(Sequence
Privileges)
.
.
.
.
.
.
. 629
REVOKE
(Server
Privileges)
.
.
.
.
.
.
.
. 631
REVOKE
(Table
Space
Privileges)
.
.
.
.
.
.
. 633
REVOKE
(Table,
View,
or
Nickname
Privileges)
635
ROLLBACK
.
.
.
.
.
.
.
.
.
.
.
.
.
. 640
SAVEPOINT
.
.
.
.
.
.
.
.
.
.
.
.
.
. 643
SELECT
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 646
SELECT
INTO
.
.
.
.
.
.
.
.
.
.
.
.
. 647
SET
CONNECTION
.
.
.
.
.
.
.
.
.
.
. 649
SET
CURRENT
DEFAULT
TRANSFORM
GROUP
651
SET
CURRENT
DEGREE
.
.
.
.
.
.
.
.
. 653
SET
CURRENT
EXPLAIN
MODE
.
.
.
.
.
. 655
SET
CURRENT
EXPLAIN
SNAPSHOT
.
.
.
.
. 658
SET
CURRENT
ISOLATION
.
.
.
.
.
.
.
. 660
SET
CURRENT
LOCK
TIMEOUT
.
.
.
.
.
. 661
SET
CURRENT
MAINTAINED
TABLE
TYPES
FOR
OPTIMIZATION
.
.
.
.
.
.
.
.
.
.
.
. 663
SET
CURRENT
PACKAGE
PATH
.
.
.
.
.
. 665
SET
CURRENT
PACKAGESET
.
.
.
.
.
.
. 669
SET
CURRENT
QUERY
OPTIMIZATION
.
.
.
. 671
SET
CURRENT
REFRESH
AGE
.
.
.
.
.
.
. 674
SET
ENCRYPTION
PASSWORD
.
.
.
.
.
.
. 676
SET
EVENT
MONITOR
STATE
.
.
.
.
.
.
. 677
SET
INTEGRITY
.
.
.
.
.
.
.
.
.
.
.
. 679
SET
PASSTHRU
.
.
.
.
.
.
.
.
.
.
.
. 694
SET
PATH
.
.
.
.
.
.
.
.
.
.
.
.
.
. 696
SET
SCHEMA
.
.
.
.
.
.
.
.
.
.
.
.
. 698
SET
SERVER
OPTION
.
.
.
.
.
.
.
.
.
. 700
SET
SESSION
AUTHORIZATION
.
.
.
.
.
. 702
SET
Variable
.
.
.
.
.
.
.
.
.
.
.
.
.
. 705
SIGNAL
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 709
UPDATE
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 712
VALUES
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 722
VALUES
INTO
.
.
.
.
.
.
.
.
.
.
.
.
. 723
WHENEVER
.
.
.
.
.
.
.
.
.
.
.
.
. 725
WHILE
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 727
Appendix
A.
DB2
Universal
Database
technical
information
.
.
.
.
.
.
.
. 729
DB2
documentation
and
help
.
.
.
.
.
.
.
. 729
DB2
documentation
updates
.
.
.
.
.
.
. 729
DB2
Information
Center
.
.
.
.
.
.
.
.
.
. 730
DB2
Information
Center
installation
scenarios
.
. 731
Installing
the
DB2
Information
Center
using
the
DB2
Setup
wizard
(UNIX)
.
.
.
.
.
.
.
.
. 734
Installing
the
DB2
Information
Center
using
the
DB2
Setup
wizard
(Windows)
.
.
.
.
.
.
.
. 736
Invoking
the
DB2
Information
Center
.
.
.
.
. 738
Updating
the
DB2
Information
Center
installed
on
your
computer
or
intranet
server
.
.
.
.
.
.
. 739
Displaying
topics
in
your
preferred
language
in
the
DB2
Information
Center
.
.
.
.
.
.
.
.
.
. 740
DB2
and
printed
documentation
.
.
.
.
. 741
Core
DB2
information
.
.
.
.
.
.
.
.
. 741
Administration
information
.
.
.
.
.
.
. 741
Application
development
information
.
.
.
. 742
Business
intelligence
information
.
.
.
.
.
. 743
DB2
Connect
information
.
.
.
.
.
.
.
. 743
Getting
started
information
.
.
.
.
.
.
.
. 743
Tutorial
information
.
.
.
.
.
.
.
.
.
. 744
Optional
component
information
.
.
.
.
.
. 744
Release
notes
.
.
.
.
.
.
.
.
.
.
.
. 745
Printing
DB2
books
from
files
.
.
.
.
.
. 746
Ordering
printed
DB2
books
.
.
.
.
.
.
.
. 746
Invoking
contextual
help
from
a
DB2
tool
.
.
.
. 747
Invoking
message
help
from
the
command
line
processor
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 748
Invoking
command
help
from
the
command
line
processor
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 749
Invoking
SQL
state
help
from
the
command
line
processor
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 749
DB2
tutorials
.
.
.
.
.
.
.
.
.
.
.
.
. 749
DB2
troubleshooting
information
.
.
.
.
.
.
. 750
Accessibility
.
.
.
.
.
.
.
.
.
.
.
.
.
. 751
Keyboard
input
and
navigation
.
.
.
.
.
. 751
Accessible
display
.
.
.
.
.
.
.
.
.
.
. 751
Compatibility
with
assistive
technologies
.
.
. 752
Accessible
documentation
.
.
.
.
.
.
.
. 752
Dotted
decimal
syntax
diagrams
.
.
.
.
.
.
. 752
Common
Criteria
certification
of
DB2
Universal
Database
products
.
.
.
.
.
.
.
.
.
.
.
. 754
Appendix
B.
Notices
.
.
.
.
.
.
.
. 755
Trademarks
.
.
.
.
.
.
.
.
.
.
.
.
.
. 757
Index
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 759
Contacting
IBM
.
.
.
.
.
.
.
.
.
. 769
Product
information
.
.
.
.
.
.
.
.
.
.
. 769
iv
SQL
Reference,
Volume
2
||
||
||||
||
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
About
this
book
The
SQL
Reference
in
its
two
volumes
defines
the
SQL
language
used
by
DB2
Universal
Database
Version
8,
and
includes:
v
Information
about
relational
database
concepts,
language
elements,
functions,
and
the
forms
of
queries
(Volume
1).
v
Information
about
the
syntax
and
semantics
of
SQL
statements
(Volume
2).
Who
should
use
this
book
This
book
is
intended
for
anyone
who
wants
to
use
the
Structured
Query
Language
(SQL)
to
access
a
database.
It
is
primarily
for
programmers
and
database
administrators,
but
it
can
also
be
used
by
those
who
access
databases
through
the
command
line
processor
(CLP).
This
book
is
a
reference
rather
than
a
tutorial.
It
assumes
that
you
will
be
writing
application
programs
and
therefore
presents
the
full
functions
of
the
database
manager.
How
this
book
is
structured
This
book
contains
information
about
the
following
major
topics:
v
“Statements,”
on
page
1
contains
syntax
diagrams,
semantic
descriptions,
rules,
and
examples
of
all
SQL
statements,
including
SQL
procedure
statements.
A
brief
overview
of
Volume
1
The
first
volume
of
the
SQL
Reference
contains
information
about
relational
database
concepts,
language
elements,
functions,
and
the
forms
of
queries.
The
specific
chapters
and
appendixes
in
that
volume
are
briefly
described
here:
v
“Concepts”
discusses
the
basic
concepts
of
relational
databases
and
SQL.
v
“Language
elements”
describes
the
basic
syntax
of
SQL
and
the
language
elements
that
are
common
to
many
SQL
statements.
v
“Functions”
contains
syntax
diagrams,
semantic
descriptions,
rules,
and
usage
examples
of
SQL
column
and
scalar
functions.
v
“Queries”
describes
the
various
forms
of
a
query.
v
“SQL
limits”
lists
the
SQL
limitations.
v
“SQL
communications
area
(SQLCA)”
describes
the
SQLCA
structure.
v
“SQL
descriptor
area
(SQLDA)”
describes
the
SQLDA
structure.
v
“Catalog
views”
describes
the
database
catalog
views.
v
“Federated
systems”
describes
options
and
type
mappings
for
federated
systems.
v
“Sample
database
tables”
describes
the
sample
tables
used
in
examples.
v
“Reserved
schema
names
and
reserved
words”
contains
the
reserved
schema
names
and
the
reserved
words
for
the
IBM
SQL
and
ISO/ANSI
SQL99
standards.
v
“Interaction
of
triggers
and
constraints”
discusses
the
interaction
of
triggers
and
referential
constraints.
v
“Explain
tables”
describes
the
Explain
tables.
©
Copyright
IBM
Corp.
1993
-
2004
v
v
“Explain
register
values”
describes
the
interaction
of
the
CURRENT
EXPLAIN
MODE
and
CURRENT
EXPLAIN
SNAPSHOT
special
register
values
with
each
other
and
with
the
PREP
and
BIND
commands.
v
“Exception
tables”
contains
information
about
user-created
tables
that
are
used
with
the
SET
INTEGRITY
statement.
v
“SQL
statements
allowed
in
routines”
lists
the
SQL
statements
that
are
allowed
to
execute
in
routines
with
different
SQL
data
access
contexts.
v
“CALL”
describes
the
CALL
statement
that
can
be
invoked
from
a
compiled
statement.
v
“Japanese
and
traditional-Chinese
EUC
considerations”
lists
considerations
when
using
extended
UNIX
code
(EUC)
character
sets.
v
“BNF
specifications
for
DATALINKs”
contains
the
Backus-Naur
form
(BNF)
specifications
for
DATALINKs.
How
to
read
the
syntax
diagrams
Throughout
this
book,
syntax
is
described
using
the
structure
defined
as
follows:
Read
the
syntax
diagrams
from
left
to
right
and
top
to
bottom,
following
the
path
of
the
line.
The
��───
symbol
indicates
the
beginning
of
a
syntax
diagram.
The
───�
symbol
indicates
that
the
syntax
is
continued
on
the
next
line.
The
�───
symbol
indicates
that
the
syntax
is
continued
from
the
previous
line.
The
──��
symbol
indicates
the
end
of
a
syntax
diagram.
Syntax
fragments
start
with
the
├───
symbol
and
end
with
the
───┤
symbol.
Required
items
appear
on
the
horizontal
line
(the
main
path).
��
required_item
��
Optional
items
appear
below
the
main
path.
��
required_item
optional_item
��
If
an
optional
item
appears
above
the
main
path,
that
item
has
no
effect
on
execution,
and
is
used
only
for
readability.
��
required_item
optional_item
��
If
you
can
choose
from
two
or
more
items,
they
appear
in
a
stack.
If
you
must
choose
one
of
the
items,
one
item
of
the
stack
appears
on
the
main
path.
A
brief
overview
of
Volume
1
vi
SQL
Reference,
Volume
2
��
required_item
required_choice1
required_choice2
��
If
choosing
one
of
the
items
is
optional,
the
entire
stack
appears
below
the
main
path.
��
required_item
optional_choice1
optional_choice2
��
If
one
of
the
items
is
the
default,
it
will
appear
above
the
main
path,
and
the
remaining
choices
will
be
shown
below.
��
required_item
default_choice
optional_choice
optional_choice
��
An
arrow
returning
to
the
left,
above
the
main
line,
indicates
an
item
that
can
be
repeated.
In
this
case,
repeated
items
must
be
separated
by
one
or
more
blanks.
��
required_item
�
repeatable_item
��
If
the
repeat
arrow
contains
a
comma,
you
must
separate
repeated
items
with
a
comma.
��
required_item
�
,
repeatable_item
��
A
repeat
arrow
above
a
stack
indicates
that
you
can
make
more
than
one
choice
from
the
stacked
items
or
repeat
a
single
choice.
Keywords
appear
in
uppercase
(for
example,
FROM).
They
must
be
spelled
exactly
as
shown.
Variables
appear
in
lowercase
(for
example,
column-name).
They
represent
user-supplied
names
or
values
in
the
syntax.
If
punctuation
marks,
parentheses,
arithmetic
operators,
or
other
such
symbols
are
shown,
you
must
enter
them
as
part
of
the
syntax.
Sometimes
a
single
variable
represents
a
larger
fragment
of
the
syntax.
For
example,
in
the
following
diagram,
the
variable
parameter-block
represents
the
whole
syntax
fragment
that
is
labeled
parameter-block:
��
required_item
parameter-block
��
How
to
read
the
syntax
diagrams
About
this
book
vii
parameter-block:
parameter1
parameter2
parameter3
parameter4
Adjacent
segments
occurring
between
“large
bullets”
(*)
may
be
specified
in
any
sequence.
��
required_item
item1
*
item2
*
item3
*
item4
��
The
above
diagram
shows
that
item2
and
item3
may
be
specified
in
either
order.
Both
of
the
following
are
valid:
required_item
item1
item2
item3
item4
required_item
item1
item3
item2
item4
Common
syntax
elements
The
following
sections
describe
a
number
of
syntax
fragments
that
are
used
in
syntax
diagrams.
The
fragments
are
referenced
as
follows:
��
fragment
��
Function
designator
A
function
designator
uniquely
identifies
a
single
function.
Function
designators
typically
appear
in
DDL
statements
for
functions
(such
as
DROP
or
ALTER).
Syntax:
function-designator:
�
FUNCTION
function-name
(
)
,
(
data-type
)
SPECIFIC
FUNCTION
specific-name
Description:
FUNCTION
function-name
Identifies
a
particular
function,
and
is
valid
only
if
there
is
exactly
one
function
instance
with
the
name
function-name
in
the
schema.
The
identified
function
can
have
any
number
of
parameters
defined
for
it.
In
dynamic
SQL
statements,
the
CURRENT
SCHEMA
special
register
is
used
as
a
qualifier
for
an
unqualified
object
name.
In
static
SQL
statements,
the
QUALIFIER
precompile/bind
option
implicitly
specifies
the
qualifier
for
unqualified
object
names.
If
no
function
by
this
name
exists
in
the
named
or
implied
schema,
an
error
(SQLSTATE
42704)
is
raised.
If
there
is
more
than
one
instance
of
the
function
in
the
named
or
implied
schema,
an
error
(SQLSTATE
42725)
is
raised.
How
to
read
the
syntax
diagrams
viii
SQL
Reference,
Volume
2
FUNCTION
function-name
(data-type,...)
Provides
the
function
signature,
which
uniquely
identifies
the
function.
The
function
resolution
algorithm
is
not
used.
function-name
Specifies
the
name
of
the
function.
In
dynamic
SQL
statements,
the
CURRENT
SCHEMA
special
register
is
used
as
a
qualifier
for
an
unqualified
object
name.
In
static
SQL
statements,
the
QUALIFIER
precompile/bind
option
implicitly
specifies
the
qualifier
for
unqualified
object
names.
(data-type,...)
Values
must
match
the
data
types
that
were
specified
(in
the
corresponding
position)
on
the
CREATE
FUNCTION
statement.
The
number
of
data
types,
and
the
logical
concatenation
of
the
data
types,
is
used
to
identify
the
specific
function
instance.
If
a
data
type
is
unqualified,
the
type
name
is
resolved
by
searching
the
schemas
on
the
SQL
path.
This
also
applies
to
data
type
names
specified
for
a
REFERENCE
type.
It
is
not
necessary
to
specify
the
length,
precision,
or
scale
for
the
parameterized
data
types.
Instead,
an
empty
set
of
parentheses
can
be
coded
to
indicate
that
these
attributes
are
to
be
ignored
when
looking
for
a
data
type
match.
FLOAT()
cannot
be
used
(SQLSTATE
42601),
because
the
parameter
value
indicates
different
data
types
(REAL
or
DOUBLE).
If
length,
precision,
or
scale
is
coded,
the
value
must
exactly
match
that
specified
in
the
CREATE
FUNCTION
statement.
A
type
of
FLOAT(n)
does
not
need
to
match
the
defined
value
for
n,
because
0
<
n
<
25
means
REAL,
and
24
<
n
<
54
means
DOUBLE.
Matching
occurs
on
the
basis
of
whether
the
type
is
REAL
or
DOUBLE.
If
no
function
with
the
specified
signature
exists
in
the
named
or
implied
schema,
an
error
(SQLSTATE
42883)
is
raised.
SPECIFIC
FUNCTION
specific-name
Identifies
a
particular
user-defined
function,
using
the
name
that
is
specified
or
defaulted
to
at
function
creation
time.
In
dynamic
SQL
statements,
the
CURRENT
SCHEMA
special
register
is
used
as
a
qualifier
for
an
unqualified
object
name.
In
static
SQL
statements,
the
QUALIFIER
precompile/bind
option
implicitly
specifies
the
qualifier
for
unqualified
object
names.
The
specific-name
must
identify
a
specific
function
instance
in
the
named
or
implied
schema;
otherwise,
an
error
(SQLSTATE
42704)
is
raised.
Method
designator
A
method
designator
uniquely
identifies
a
single
method.
Method
designators
typically
appear
in
DDL
statements
for
methods
(such
as
DROP
or
ALTER).
Syntax:
Function
designator
About
this
book
ix
method-designator:
�
METHOD
method-name
FOR
type-name
(
)
,
(
data-type
)
SPECIFIC
METHOD
specific-name
Description:
METHOD
method-name
Identifies
a
particular
method,
and
is
valid
only
if
there
is
exactly
one
method
instance
with
the
name
method-name
for
the
type
type-name.
The
identified
method
can
have
any
number
of
parameters
defined
for
it.
If
no
method
by
this
name
exists
for
the
type,
an
error
(SQLSTATE
42704)
is
raised.
If
there
is
more
than
one
instance
of
the
method
for
the
type,
an
error
(SQLSTATE
42725)
is
raised.
METHOD
method-name
(data-type,...)
Provides
the
method
signature,
which
uniquely
identifies
the
method.
The
method
resolution
algorithm
is
not
used.
method-name
Specifies
the
name
of
the
method
for
the
type
type-name.
(data-type,...)
Values
must
match
the
data
types
that
were
specified
(in
the
corresponding
position)
on
the
CREATE
TYPE
statement.
The
number
of
data
types,
and
the
logical
concatenation
of
the
data
types,
is
used
to
identify
the
specific
method
instance.
If
a
data
type
is
unqualified,
the
type
name
is
resolved
by
searching
the
schemas
on
the
SQL
path.
This
also
applies
to
data
type
names
specified
for
a
REFERENCE
type.
It
is
not
necessary
to
specify
the
length,
precision,
or
scale
for
the
parameterized
data
types.
Instead,
an
empty
set
of
parentheses
can
be
coded
to
indicate
that
these
attributes
are
to
be
ignored
when
looking
for
a
data
type
match.
FLOAT()
cannot
be
used
(SQLSTATE
42601),
because
the
parameter
value
indicates
different
data
types
(REAL
or
DOUBLE).
If
length,
precision,
or
scale
is
coded,
the
value
must
exactly
match
that
specified
in
the
CREATE
TYPE
statement.
A
type
of
FLOAT(n)
does
not
need
to
match
the
defined
value
for
n,
because
0
<
n
<
25
means
REAL,
and
24
<
n
<
54
means
DOUBLE.
Matching
occurs
on
the
basis
of
whether
the
type
is
REAL
or
DOUBLE.
If
no
method
with
the
specified
signature
exists
for
the
type
in
the
named
or
implied
schema,
an
error
(SQLSTATE
42883)
is
raised.
FOR
type-name
Names
the
type
with
which
the
specified
method
is
to
be
associated.
The
name
must
identify
a
type
already
described
in
the
catalog
(SQLSTATE
42704).
In
dynamic
SQL
statements,
the
CURRENT
SCHEMA
special
register
is
used
as
a
qualifier
for
an
unqualified
object
name.
In
static
SQL
statements,
the
QUALIFIER
precompile/bind
option
implicitly
specifies
the
qualifier
for
unqualified
object
names.
Method
designator
x
SQL
Reference,
Volume
2
SPECIFIC
METHOD
specific-name
Identifies
a
particular
method,
using
the
name
that
is
specified
or
defaulted
to
at
method
creation
time.
In
dynamic
SQL
statements,
the
CURRENT
SCHEMA
special
register
is
used
as
a
qualifier
for
an
unqualified
object
name.
In
static
SQL
statements,
the
QUALIFIER
precompile/bind
option
implicitly
specifies
the
qualifier
for
unqualified
object
names.
The
specific-name
must
identify
a
specific
method
instance
in
the
named
or
implied
schema;
otherwise,
an
error
(SQLSTATE
42704)
is
raised.
Procedure
designator
A
procedure
designator
uniquely
identifies
a
single
stored
procedure.
Procedure
designators
typically
appear
in
DDL
statements
for
procedures
(such
as
DROP
or
ALTER).
Syntax:
procedure-designator:
�
PROCEDURE
procedure-name
(
)
,
(
data-type
)
SPECIFIC
PROCEDURE
specific-name
Description:
PROCEDURE
procedure-name
Identifies
a
particular
procedure,
and
is
valid
only
if
there
is
exactly
one
procedure
instance
with
the
name
procedure-name
in
the
schema.
The
identified
procedure
can
have
any
number
of
parameters
defined
for
it.
In
dynamic
SQL
statements,
the
CURRENT
SCHEMA
special
register
is
used
as
a
qualifier
for
an
unqualified
object
name.
In
static
SQL
statements,
the
QUALIFIER
precompile/bind
option
implicitly
specifies
the
qualifier
for
unqualified
object
names.
If
no
procedure
by
this
name
exists
in
the
named
or
implied
schema,
an
error
(SQLSTATE
42704)
is
raised.
If
there
is
more
than
one
instance
of
the
procedure
in
the
named
or
implied
schema,
an
error
(SQLSTATE
42725)
is
raised.
PROCEDURE
procedure-name
(data-type,...)
Provides
the
procedure
signature,
which
uniquely
identifies
the
procedure.
The
procedure
resolution
algorithm
is
not
used.
procedure-name
Specifies
the
name
of
the
procedure.
In
dynamic
SQL
statements,
the
CURRENT
SCHEMA
special
register
is
used
as
a
qualifier
for
an
unqualified
object
name.
In
static
SQL
statements,
the
QUALIFIER
precompile/bind
option
implicitly
specifies
the
qualifier
for
unqualified
object
names.
(data-type,...)
Values
must
match
the
data
types
that
were
specified
(in
the
corresponding
position)
on
the
CREATE
PROCEDURE
statement.
The
number
of
data
types,
and
the
logical
concatenation
of
the
data
types,
is
used
to
identify
the
specific
procedure
instance.
If
a
data
type
is
unqualified,
the
type
name
is
resolved
by
searching
the
schemas
on
the
SQL
path.
This
also
applies
to
data
type
names
specified
for
a
REFERENCE
type.
Method
designator
About
this
book
xi
It
is
not
necessary
to
specify
the
length,
precision,
or
scale
for
the
parameterized
data
types.
Instead,
an
empty
set
of
parentheses
can
be
coded
to
indicate
that
these
attributes
are
to
be
ignored
when
looking
for
a
data
type
match.
FLOAT()
cannot
be
used
(SQLSTATE
42601),
because
the
parameter
value
indicates
different
data
types
(REAL
or
DOUBLE).
If
length,
precision,
or
scale
is
coded,
the
value
must
exactly
match
that
specified
in
the
CREATE
PROCEDURE
statement.
A
type
of
FLOAT(n)
does
not
need
to
match
the
defined
value
for
n,
because
0
<
n
<
25
means
REAL,
and
24
<
n
<
54
means
DOUBLE.
Matching
occurs
on
the
basis
of
whether
the
type
is
REAL
or
DOUBLE.
If
no
procedure
with
the
specified
signature
exists
in
the
named
or
implied
schema,
an
error
(SQLSTATE
42883)
is
raised.
SPECIFIC
PROCEDURE
specific-name
Identifies
a
particular
procedure,
using
the
name
that
is
specified
or
defaulted
to
at
procedure
creation
time.
In
dynamic
SQL
statements,
the
CURRENT
SCHEMA
special
register
is
used
as
a
qualifier
for
an
unqualified
object
name.
In
static
SQL
statements,
the
QUALIFIER
precompile/bind
option
implicitly
specifies
the
qualifier
for
unqualified
object
names.
The
specific-name
must
identify
a
specific
procedure
instance
in
the
named
or
implied
schema;
otherwise,
an
error
(SQLSTATE
42704)
is
raised.
Conventions
used
in
this
manual
This
section
specifies
some
conventions
which
are
used
consistently
throughout
this
manual.
Error
conditions
An
error
condition
is
indicated
within
the
text
of
the
manual
by
listing
the
SQLSTATE
associated
with
the
error
in
parentheses.
For
example:
A
duplicate
signature
raises
an
SQL
error
(SQLSTATE
42723).
Highlighting
conventions
The
following
conventions
are
used
in
this
book.
Bold
Indicates
commands,
keywords,
and
other
items
whose
names
are
predefined
by
the
system.
Italics
Indicates
one
of
the
following:
v
Names
or
values
(variables)
that
must
be
supplied
by
the
user.
v
General
emphasis.
v
The
introduction
of
a
new
term.
v
A
reference
to
another
source
of
information.
Monospace
Indicates
one
of
the
following:
v
Files
and
directories.
v
Information
that
you
are
instructed
to
type
at
a
command
prompt
or
in
a
window.
v
Examples
of
specific
data
values.
v
Examples
of
text
similar
to
what
may
be
displayed
by
the
system.
v
Examples
of
system
messages.
Procedure
designator
xii
SQL
Reference,
Volume
2
Related
documentation
The
following
publications
may
prove
useful
in
preparing
applications:
v
Administration
Guide
–
Contains
information
required
to
design,
implement,
and
maintain
a
database
to
be
accessed
either
locally
or
in
a
client/server
environment.v
Application
Development
Guide
–
Discusses
the
application
development
process
and
how
to
code,
compile,
and
execute
application
programs
that
use
embedded
SQL
and
APIs
to
access
the
database.v
DB2
Universal
Database
for
iSeries
SQL
Reference
–
This
book
defines
Structured
Query
Language
(SQL)
as
supported
by
DB2
Query
Manager
and
SQL
Development
Kit
on
iSeries
(AS/400).
It
contains
reference
information
for
the
tasks
of
system
administration,
database
administration,
application
programming,
and
operation.
This
manual
includes
syntax,
usage
notes,
keywords,
and
examples
for
each
of
the
SQL
statements
used
on
iSeries
(AS/400)
systems
running
DB2.v
DB2
Universal
Database
for
z/OS
and
OS/390
SQL
Reference
–
This
book
defines
Structured
Query
Language
(SQL)
used
in
DB2
for
z/OS
(OS/390).
It
provides
query
forms,
SQL
statements,
SQL
procedure
statements,
DB2
limits,
SQLCA,
SQLDA,
catalog
tables,
and
SQL
reserved
words
for
z/OS
(OS/390)
systems
running
DB2.v
DB2
Spatial
Extender
User’s
Guide
and
Reference
–
This
book
discusses
how
to
write
applications
to
create
and
use
a
geographic
information
system
(GIS).
Creating
and
using
a
GIS
involves
supplying
a
database
with
resources
and
then
querying
the
data
to
obtain
information
such
as
locations,
distances,
and
distributions
within
areas.v
IBM
SQL
Reference
–
This
book
contains
all
the
common
elements
of
SQL
that
span
IBM’s
database
products.
It
provides
limits
and
rules
that
assist
in
preparing
portable
programs
using
IBM
databases.
This
manual
provides
a
list
of
SQL
extensions
and
incompatibilities
among
the
following
standards
and
products:
SQL92E,
XPG4-SQL,
IBM-SQL
and
the
IBM
relational
database
products.v
American
National
Standard
X3.135-1992,
Database
Language
SQL
–
Contains
the
ANSI
standard
definition
of
SQL.v
ISO/IEC
9075:1992,
Database
Language
SQL
–
Contains
the
1992
ISO
standard
definition
of
SQL.v
ISO/IEC
9075-2:1999,
Database
Language
SQL
--
Part
2:
Foundation
(SQL/Foundation)
–
Contains
a
large
portion
of
the
1999
ISO
standard
definition
of
SQL.v
ISO/IEC
9075-4:1999,
Database
Language
SQL
--
Part
4:
Persistent
Stored
Modules
(SQL/PSM)
–
Contains
the
1999
ISO
standard
definition
for
SQL
procedure
control
statements.v
ISO/IEC
9075-5:1999,
Database
Language
SQL
--
Part
4:
Host
Language
Bindings
(SQL/Bindings)
–
Contains
the
1999
ISO
standard
definition
for
host
language
bindings
and
dynamic
SQL.
Related
documentation
About
this
book
xiii
Related
documentation
xiv
SQL
Reference,
Volume
2
Statements
This
chapter
contains
syntax
diagrams,
semantic
descriptions,
rules,
and
examples
of
the
use
of
the
SQL
statements,
including
the
statements
that
constitute
the
body
of
an
SQL
routine,
trigger,
or
dynamic
compound
statement.
Supported
SQL
statements
The
following
table
lists
the
supported
SQL
statements.
Table
1.
SQL
Statements
SQL
Statement
Purpose
“ALLOCATE
CURSOR”
on
page
11
Allocates
a
cursor
for
the
result
set
identified
by
the
result
set
locator
variable.
“ALTER
BUFFERPOOL”
on
page
13
Changes
the
definition
of
a
buffer
pool.
“ALTER
DATABASE
PARTITION
GROUP”
on
page
15
Changes
the
definition
of
a
database
partition
group.
“ALTER
FUNCTION”
on
page
18
Modifies
an
existing
function
by
changing
the
properties
of
the
function.
“ALTER
METHOD”
on
page
21
Modifies
an
existing
method
by
changing
the
method
body
associated
with
the
method.
“ALTER
NICKNAME”
on
page
23
Changes
the
definition
of
a
nickname.
“ALTER
PROCEDURE”
on
page
30
Modifies
an
existing
procedure
by
changing
the
properties
of
the
procedure.
“ALTER
SEQUENCE”
on
page
33
Changes
the
definition
of
a
sequence.
“ALTER
SERVER”
on
page
37
Changes
the
definition
of
a
data
source
in
a
federated
system.
“ALTER
TABLE”
on
page
40
Changes
the
definition
of
a
table.
“ALTER
TABLESPACE”
on
page
72
Changes
the
definition
of
a
table
space.
“ALTER
TYPE
(Structured)”
on
page
79
Changes
the
definition
of
a
structured
type.
“ALTER
USER
MAPPING”
on
page
86
Changes
the
definition
of
a
user
authorization
mapping.
“ALTER
VIEW”
on
page
88
Changes
the
definition
of
a
view
by
altering
a
reference
type
column
to
add
a
scope.
“ALTER
WRAPPER”
on
page
90
Updates
the
options
that,
along
with
a
wrapper
module,
are
used
to
access
data
sources
of
a
specific
type.
“ASSOCIATE
LOCATORS”
on
page
92
Gets
the
result
set
locator
value
for
each
result
set
returned
by
a
stored
procedure.
“BEGIN
DECLARE
SECTION”
on
page
94
Marks
the
beginning
of
a
host
variable
declaration
section.
“CALL”
on
page
96
Calls
a
stored
procedure.
“CASE”
on
page
101
Selects
an
execution
path
based
on
multiple
conditions.
“CLOSE”
on
page
104
Closes
a
cursor.
“COMMENT”
on
page
106
Replaces
or
adds
a
comment
to
the
description
of
an
object.
“COMMIT”
on
page
116
Terminates
a
unit
of
work
and
commits
the
database
changes
made
by
that
unit
of
work.
“Compound
SQL
(Dynamic)”
on
page
118
Combines
one
or
more
other
SQL
statements
into
an
dynamic
block.
©
Copyright
IBM
Corp.
1993
-
2004
1
|||
Table
1.
SQL
Statements
(continued)
SQL
Statement
Purpose
“Compound
SQL
(Embedded)”
on
page
123
Combines
one
or
more
other
SQL
statements
into
an
executable
block.
“Compound
SQL
(Procedure)”
on
page
127
Groups
other
statements
together
in
an
SQL
procedure.
“CONNECT
(Type
1)”
on
page
135
Connects
to
an
application
server
according
to
the
rules
for
remote
unit
of
work.
“CONNECT
(Type
2)”
on
page
142
Connects
to
an
application
server
according
to
the
rules
for
application-directed
distributed
unit
of
work.
“CREATE
ALIAS”
on
page
149
Defines
an
alias
for
a
table,
view,
or
another
alias.
“CREATE
BUFFERPOOL”
on
page
152
Creates
a
new
buffer
pool.
“CREATE
DATABASE
PARTITION
GROUP”
on
page
156
Defines
a
database
partition
group.
“CREATE
DISTINCT
TYPE”
on
page
158
Defines
a
distinct
data
type.
“CREATE
EVENT
MONITOR”
on
page
164
Specifies
events
in
the
database
to
monitor.
“CREATE
FUNCTION”
on
page
180
Registers
a
user-defined
function.
“CREATE
FUNCTION
(External
Scalar)”
on
page
181
Registers
a
user-defined
external
scalar
function.
“CREATE
FUNCTION
(External
Table)”
on
page
204
Registers
a
user-defined
external
table
function.
“CREATE
FUNCTION
(OLE
DB
External
Table)”
on
page
221
Registers
a
user-defined
OLE
DB
external
table
function.
“CREATE
FUNCTION
(Sourced
or
Template)”
on
page
228
Registers
a
user-defined
sourced
function.
“CREATE
FUNCTION
(SQL
Scalar,
Table,
or
Row)”
on
page
238
Registers
and
defines
a
user-defined
SQL
function.
“CREATE
FUNCTION
MAPPING”
on
page
247
Defines
a
function
mapping.
“CREATE
INDEX”
on
page
252
Defines
an
index
on
a
table.
“CREATE
INDEX
EXTENSION”
on
page
261
Defines
an
extension
object
for
use
with
indexes
on
tables
with
structured
or
distinct
type
columns.
“CREATE
METHOD”
on
page
267
Associates
a
method
body
with
a
previously
defined
method
specification.
“CREATE
NICKNAME”
on
page
273
Defines
a
nickname.
“CREATE
PROCEDURE”
on
page
285
Registers
a
stored
procedure.
“CREATE
PROCEDURE
(External)”
on
page
286
Registers
an
external
stored
procedure.
“CREATE
PROCEDURE
(SQL)”
on
page
299
Registers
an
SQL
stored
procedure.
“CREATE
SCHEMA”
on
page
305
Defines
a
schema.
“CREATE
SEQUENCE”
on
page
308
Defines
a
sequence.
“CREATE
SERVER”
on
page
312
Defines
a
data
source
to
a
federated
database.
“CREATE
TABLE”
on
page
316
Defines
a
table.
“CREATE
TABLESPACE”
on
page
374
Defines
a
table
space.
“CREATE
TRANSFORM”
on
page
383
Defines
transformation
functions.
“CREATE
TRIGGER”
on
page
390
Defines
a
trigger.
“CREATE
TYPE
(Structured)”
on
page
401
Defines
a
structured
data
type.
Supported
SQL
statements
2
SQL
Reference,
Volume
2
Table
1.
SQL
Statements
(continued)
SQL
Statement
Purpose
“CREATE
TYPE
MAPPING”
on
page
425
Defines
a
mapping
between
data
types.
“CREATE
USER
MAPPING”
on
page
430
Defines
a
mapping
between
user
authorizations.
“CREATE
VIEW”
on
page
432
Defines
a
view
of
one
or
more
table,
view
or
nickname.
“CREATE
WRAPPER”
on
page
446
Registers
a
wrapper.
“DECLARE
CURSOR”
on
page
448
Defines
an
SQL
cursor.
“DECLARE
GLOBAL
TEMPORARY
TABLE”
on
page
454
Defines
the
Global
Temporary
Table.
“DELETE”
on
page
462
Deletes
one
or
more
rows
from
a
table.
“DESCRIBE”
on
page
469
Describes
the
result
columns
of
a
prepared
SELECT
statement.
“DISCONNECT”
on
page
473
Terminates
one
or
more
connections
when
there
is
no
active
unit
of
work.
“DROP”
on
page
476
Deletes
objects
in
the
database.
“END
DECLARE
SECTION”
on
page
500
Marks
the
end
of
a
host
variable
declaration
section.
“EXECUTE”
on
page
501
Executes
a
prepared
SQL
statement.
“EXECUTE
IMMEDIATE”
on
page
507
Prepares
and
executes
an
SQL
statement.
“EXPLAIN”
on
page
510
Captures
information
about
the
chosen
access
plan.
“FETCH”
on
page
515
Assigns
values
of
a
row
to
host
variables.
“FLUSH
EVENT
MONITOR”
on
page
518
Writes
out
the
active
internal
buffer
of
an
event
monitor.
“FLUSH
PACKAGE
CACHE”
on
page
519
Removes
all
cached
dynamic
SQL
statements
currently
in
the
package
cache.
“FOR”
on
page
520
Executes
a
statement
or
group
of
statements
for
each
row
of
a
table.
“FREE
LOCATOR”
on
page
523
Removes
the
association
between
a
locator
variable
and
its
value.
“GET
DIAGNOSTICS”
on
page
524
Used
to
obtain
information
about
the
previously
executed
SQL
statement.
“GOTO”
on
page
527
Used
to
branch
to
a
user-defined
label
within
an
SQL
procedure.
“GRANT
(Database
Authorities)”
on
page
529
Grants
authorities
on
the
entire
database.
“GRANT
(Index
Privileges)”
on
page
533
Grants
the
CONTROL
privilege
on
indexes
in
the
database.
“GRANT
(Package
Privileges)”
on
page
535
Grants
privileges
on
packages
in
the
database.
“GRANT
(Routine
Privileges)”
on
page
538
Grants
privileges
on
a
routine
(function,
method,
or
procedure).
“GRANT
(Schema
Privileges)”
on
page
542
Grants
privileges
on
a
schema.
“GRANT
(Sequence
Privileges)”
on
page
545
Grants
privileges
on
a
sequence.
“GRANT
(Server
Privileges)”
on
page
547
Grants
privileges
to
query
a
specific
data
source.
“GRANT
(Table
Space
Privileges)”
on
page
549
Grants
privileges
on
a
tablespace.
“GRANT
(Table,
View,
or
Nickname
Privileges)”
on
page
551
Grants
privileges
on
tables,
views
and
nicknames.
“IF”
on
page
558
Selects
an
execution
path
based
on
the
evaluation
of
a
condition.
“INCLUDE”
on
page
560
Inserts
code
or
declarations
into
a
source
program.
“INSERT”
on
page
562
Inserts
one
or
more
rows
into
a
table.
“ITERATE”
on
page
571
Causes
the
flow
of
control
to
return
to
the
beginning
of
a
labelled
loop.
“LEAVE”
on
page
572
Transfers
program
control
out
of
a
loop
or
a
compound
statement.
Supported
SQL
statements
Statements
3
Table
1.
SQL
Statements
(continued)
SQL
Statement
Purpose
“LOCK
TABLE”
on
page
574
Either
prevents
concurrent
processes
from
changing
a
table
or
prevents
concurrent
processes
from
using
a
table.
“LOOP”
on
page
576
Repeats
the
execution
of
a
statement
or
a
group
of
statements.
“MERGE”
on
page
578
Updates
a
target
(a
table
or
view)
using
data
from
a
source
(result
of
a
table
reference).
“OPEN”
on
page
587
Prepares
a
cursor
that
will
be
used
to
retrieve
values
when
the
FETCH
statement
is
issued.
“PREPARE”
on
page
592
Prepares
an
SQL
statement
(with
optional
parameters)
for
execution.
“REFRESH
TABLE”
on
page
601
Refreshes
the
data
in
a
materialized
query
table.
“RELEASE
(Connection)”
on
page
603
Places
one
or
more
connections
in
the
release-pending
state.
“RELEASE
SAVEPOINT”
on
page
605
Releases
a
savepoint
within
a
transaction.
“RENAME”
on
page
606
Renames
an
existing
table.
“RENAME
TABLESPACE”
on
page
608
Renames
an
existing
tablespace.
“REPEAT”
on
page
609
Executes
a
statement
or
group
of
statements
until
a
search
condition
is
true.
“RESIGNAL”
on
page
611
Used
to
resignal
an
error
or
warning
condition.
“RETURN”
on
page
613
Used
to
return
from
a
routine.
“REVOKE
(Database
Authorities)”
on
page
615
Revokes
authorities
from
the
entire
database.
“REVOKE
(Index
Privileges)”
on
page
619
Revokes
the
CONTROL
privilege
on
given
indexes.
“REVOKE
(Package
Privileges)”
on
page
621
Revokes
privileges
from
given
packages
in
the
database.
“REVOKE
(Routine
Privileges)”
on
page
624
Revokes
privileges
on
a
routine
(function,
method,
or
procedure).
“REVOKE
(Schema
Privileges)”
on
page
627
Revokes
privileges
on
a
schema.
“REVOKE
(Sequence
Privileges)”
on
page
629
Revokes
privileges
on
a
sequence.
“REVOKE
(Server
Privileges)”
on
page
631
Revokes
privileges
to
query
a
specific
data
source.
“REVOKE
(Table
Space
Privileges)”
on
page
633
Revokes
the
USE
privilege
on
a
given
table
space.
“REVOKE
(Table,
View,
or
Nickname
Privileges)”
on
page
635
Revokes
privileges
from
given
tables,
views
or
nicknames.
“ROLLBACK”
on
page
640
Terminates
a
unit
of
work
and
backs
out
the
database
changes
made
by
that
unit
of
work.
“SAVEPOINT”
on
page
643
Sets
a
savepoint
within
a
transaction.
“SELECT
INTO”
on
page
647
Specifies
a
result
table
of
no
more
than
one
row
and
assigns
the
values
to
host
variables.
“SET
CONNECTION”
on
page
649
Changes
the
state
of
a
connection
from
dormant
to
current,
making
the
specified
location
the
current
server.
“SET
CURRENT
DEFAULT
TRANSFORM
GROUP”
on
page
651
Changes
the
value
of
the
CURRENT
DEFAULT
TRANSFORM
GROUP
special
register.
“SET
CURRENT
DEGREE”
on
page
653
Changes
the
value
of
the
CURRENT
DEGREE
special
register.
“SET
CURRENT
EXPLAIN
MODE”
on
page
655
Changes
the
value
of
the
CURRENT
EXPLAIN
MODE
special
register.
“SET
CURRENT
EXPLAIN
SNAPSHOT”
on
page
658
Changes
the
value
of
the
CURRENT
EXPLAIN
SNAPSHOT
special
register.
“SET
CURRENT
ISOLATION”
on
page
660
Changes
the
value
of
the
CURRENT
ISOLATION
special
register.
Supported
SQL
statements
4
SQL
Reference,
Volume
2
|||
||
||
Table
1.
SQL
Statements
(continued)
SQL
Statement
Purpose
“SET
CURRENT
LOCK
TIMEOUT”
on
page
661
Changes
the
value
of
the
CURRENT
LOCK
TIMEOUT
special
register.
“SET
CURRENT
MAINTAINED
TABLE
TYPES
FOR
OPTIMIZATION”
on
page
663
Changes
the
value
of
the