Oracle 5.0 Reference Manual page 1053

Table of Contents

Advertisement

have only one
PRIMARY
be used as the name for any other kind of index.
If you do not have a
PRIMARY KEY
MySQL returns the first
In
tables, having a long
InnoDB
Table and Index
Structures".)
• In the created table, a
nonunique indexes. This helps the MySQL optimizer to prioritize which index to use and also more
quickly to detect duplicated
• A
can be a multiple-column index. However, you cannot create a multiple-column
PRIMARY KEY
index using the
PRIMARY KEY
single column as primary. You must use a separate
clause.
• If a
or
PRIMARY KEY
also refer to the column as
• In MySQL, the name of a
name, the index is assigned the same name as the first indexed column, with an optional suffix
(_2, _3, ...) to make it unique. You can see index names for a table using
tbl_name. See
Section 13.7.5.18,
• Some storage engines permit you to specify an index type when creating an index. The syntax for
the
specifier is
index_type
Example:
CREATE TABLE lookup
(id INT, INDEX USING BTREE (id))
ENGINE = MEMORY;
Before MySQL 5.0.60,
preferred position is after the column list. Support for use of the option before the column list will be
removed in a future MySQL release.
values specify additional options for an index.
index_option
about permissible
index_option
For more information about indexes, see
In MySQL 5.0, only the MyISAM, InnoDB, BDB, and
columns that can have
or an error results.
NULL
• For CHAR, VARCHAR, BINARY, and
leading part of column values, using
and
columns also can be indexed, but a prefix length must be given. Prefix lengths are
BLOB
TEXT
given in characters for nonbinary string types and in bytes for binary string types. That is, index
entries consist of the first
columns, and the first
columns. Indexing only a prefix of column values like this can make the index file much smaller. See
Section 8.5.1, "Column
Only the MyISAM, BDB, and
For example:
CREATE TABLE test (blob_col BLOB, INDEX(blob_col(10)));
CREATE TABLE
KEY. The name of a
and an application asks for the
index that has no
UNIQUE
PRIMARY KEY
is placed first, followed by all
PRIMARY KEY
keys.
UNIQUE
key attribute in a column specification. Doing so only marks that
index consists of only one column that has an integer type, you can
UNIQUE
in
_rowid
SELECT
is PRIMARY. For other indexes, if you do not assign a
PRIMARY KEY
"SHOW INDEX
USING
type_name.
can be given only before the index column list. As of 5.0.60, the
USING
values, see
Section 8.5.3, "How MySQL Uses
values. In other cases, you must declare indexed columns as
NULL
VARBINARY
col_name(length)
characters of each column value for CHAR, VARCHAR, and
length
bytes of each column value for BINARY, VARBINARY, and
length
Indexes".
storage engines support indexing on
InnoDB
1033
Syntax
is always PRIMARY, which thus cannot
PRIMARY KEY
PRIMARY KEY
columns as the
NULL
wastes a lot of space. (See
UNIQUE
PRIMARY KEY(index_col_name, ...)
statements.
Syntax".
USING
Section 13.1.8,
"CREATE INDEX
storage engines support indexes on
MEMORY
columns, indexes can be created that use only the
syntax to specify an index prefix length.
in your tables,
PRIMARY
KEY.
Section 14.2.9,
"InnoDB
indexes, and then the
SHOW INDEX FROM
is one such option. For details
Syntax".
Indexes".
NOT
TEXT
BLOB
and
columns.
BLOB
TEXT

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents