CREATE PROCEDURE
and
CREATE FUNCTION
Syntax
1023
• You can add an index on a column that can have
NULL
values only if you are using the
MyISAM
,
InnoDB
,
BDB
, or
MEMORY
storage engine.
• You can add an index on a
BLOB
or
TEXT
column only if you are using the
MyISAM
,
BDB
, or
InnoDB
storage engine.
An
index_col_name
specification can end with
ASC
or
DESC
. These keywords are permitted for
future extensions for specifying ascending or descending index value storage. Currently, they are
parsed but ignored; index values are always stored in ascending order.
Some storage engines permit you to specify an index type when creating an index. The permissible
index type values supported by different storage engines are shown in the following table. Where
multiple index types are listed, the first one is the default when no index type specifier is given.
Storage Engine
Permissible Index Types
MyISAM
BTREE
InnoDB
BTREE
MEMORY
/
HEAP
HASH
,
BTREE
NDB
BTREE
,
HASH
(see note in text)
Example:
CREATE TABLE lookup (id INT) ENGINE = MEMORY;
CREATE INDEX id_index ON lookup (id) USING BTREE;
BTREE
indexes are implemented by the
NDBCLUSTER
storage engine as T-tree indexes.
Note
For indexes on
NDB
table columns, the
USING
option can be specified only for
a unique index or primary key.
USING HASH
prevents the creation of an implicit
ordered index; otherwise, creating a unique index or primary key on an
NDB
table automatically results in the creation of both an ordered index and a hash
index, each of which indexes the same set of columns.
This means that a query using a unique index or primary key on a
NULL
column
is always handled by
NDB
with a full scan of the table. In particular, if you plan
to use an
IS NULL
or
IS NOT NULL
condition involving a unique index or
primary key column of an
NDB
table, you should create any such index without
USING HASH
.
The
index_type
clause cannot be used together with
SPATIAL INDEX
.
If you specify an index type that is not legal for a given storage engine, but there is another index type
available that the engine can use without affecting query results, the engine uses the available type.
The parser recognizes
RTREE
as a type name, but currently this cannot be specified for any storage
engine.
Before MySQL 5.0.60, this option can be given only before the
ON tbl_name
clause. Use of the
option in this position is deprecated as of 5.0.60 and support for it there will be removed in a future
MySQL release. If an
index_type
option is given in both the earlier and later positions, the final
option applies.
TYPE type_name
is recognized as a synonym for
USING type_name
. However,
USING
is the
preferred form.
13.1.9.
CREATE PROCEDURE
and
CREATE FUNCTION
Syntax
CREATE
[DEFINER = {
user
| CURRENT_USER }]
PROCEDURE
sp_name
([
proc_parameter
[,...]])
[
characteristic
...]
routine_body
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...