Oracle 5.0 Reference Manual page 1042

Table of Contents

Advertisement

The statement shown here creates an index using the first 10 characters of the
CREATE INDEX part_of_name ON customer (name(10));
If names in the column usually differ in the first 10 characters, this index should not be much slower
than an index created from the entire
the index file much smaller, which could save a lot of disk space and might also speed up
operations.
Prefix support and lengths of prefixes (where supported) are storage engine dependent. For example,
a prefix can be up to 1000 bytes long for
storage engine does not support prefixes (see
NDBCLUSTER
Features in MySQL
Cluster").
Note
Prefix limits are measured in bytes, whereas the prefix length in
INDEX
types (CHAR, VARCHAR, TEXT). Take this into account when specifying a prefix
length for a column that uses a multi-byte character set.
A
index creates a constraint such that all values in the index must be distinct. An error occurs
UNIQUE
if you try to add a new row with a key value that matches an existing row. This constraint does not
apply to
values except for the
NULL
multiple
values for columns that can contain NULL. If you specify a prefix value for a column in a
NULL
index, the column values must be unique within the prefix.
UNIQUE
indexes are supported only for
FULLTEXT
and
columns. Indexing always happens over the entire column; column prefix indexing is not
TEXT
supported and any prefix length is ignored if specified. See
for details of operation.
The MyISAM, InnoDB, NDB, BDB, and
(POINT
and GEOMETRY.
However, support for spatial column indexing varies among engines. Spatial and nonspatial indexes
are available according to the following rules.
Spatial indexes (created using
• Available only for
MyISAM
an error.
• Indexed columns must be
• In MySQL 5.0, the full width of each column is indexed by default, but column prefix lengths are
permitted. However, as of MySQL 5.0.40, the length is not displayed in
output.
mysqldump
containing prefixed columns is dumped and reloaded, the index is created with no prefixes. (The full
column width of each column is indexed.)
Characteristics of nonspatial indexes (created with INDEX, UNIQUE, or
• Permitted for any storage engine that supports spatial columns except ARCHIVE.
• Columns can be
NULL
• For each spatial column in a
must be specified. (This is the same requirement as for indexed
given in bytes.
• The index type for a
In MySQL 5.0:
CREATE INDEX
column. Also, using column prefixes for indexes can make
name
MyISAM
statements is interpreted as number of characters for nonbinary data
storage engine. For other engines, a
BDB
MyISAM
ARCHIVE
(Section 12.16, "Spatial
INDEX) have these characteristics:
SPATIAL
tables. Specifying
NOT
NULL.
uses that statement. As of that version, if a table with
unless the index is a primary key.
non-SPATIAL
non-SPATIAL
index depends on the storage engine. Currently, B-tree is used.
1022
Syntax
tables, and 767 bytes for
Section 17.1.5.6, "Unsupported or Missing
tables and can include only CHAR, VARCHAR,
Section 12.9, "Full-Text Search
storage engines support spatial columns such as
Extensions", describes the spatial data types.)
for other storage engines results in
SPATIAL INDEX
index except
columns, a column prefix length
POINT
BLOB
column:
name
INSERT
tables. The
InnoDB
CREATE
index permits
UNIQUE
Functions",
SHOW CREATE TABLE
indexes
SPATIAL
PRIMARY
KEY):
columns.) The prefix length is

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents