Oracle 5.0 Reference Manual page 1116

Table of Contents

Advertisement

By specifying
to find rows in the table. The alternative syntax
MySQL to not use some particular index or indexes. These hints are useful if
MySQL is using the wrong index from the list of possible indexes.
You can also use
that a table scan is assumed to be very expensive. In other words, a table scan is used only if there is
no way to use one of the given indexes to find rows in the table.
Each hint requires the names of indexes, not the names of columns. The name of a
PRIMARY. To see the index names for a table, use
An
index_name
name. If a prefix is ambiguous, an error occurs.
USE
INDEX,
decides how to find rows in the table and how to do the join. They do not affect whether an index is
used when resolving an
clause can be added to make this explicit.
Examples:
SELECT * FROM table1 USE INDEX (col1_index,col2_index)
WHERE col1=1 AND col2=2 AND col3=3;
SELECT * FROM table1 IGNORE INDEX (col3_index)
WHERE col1=1 AND col2=2 AND col3=3;
For
FULLTEXT
as follows:
• For natural language mode searches, index hints are silently ignored. For example,
INDEX(i)
For boolean mode searches, index hints are honored.
13.2.8.4.
Syntax
UNION
SELECT ...
UNION [ALL | DISTINCT] SELECT ...
[UNION [ALL | DISTINCT] SELECT ...]
is used to combine the result from multiple
UNION
The column names from the first
returned. Selected columns listed in corresponding positions of each
the same data type. (For example, the first column selected by the first statement should have the
same type as the first column selected by the other statements.)
If the data types of corresponding
in the
UNION
example, consider the following:
mysql>
SELECT REPEAT('a',1) UNION SELECT REPEAT('b',10);
+---------------+
| REPEAT('a',1) |
+---------------+
| a
| bbbbbbbbbb
+---------------+
(In some earlier versions of MySQL, only the type and length from the first
used and the second row would have been truncated to a length of 1.)
(index_list), you can tell MySQL to use only one of the named indexes
USE INDEX
INDEX, which acts like
FORCE
value need not be a full index name. It can be an unambiguous prefix of an index
INDEX, and
IGNORE
FORCE INDEX
or
ORDER BY
searches, index hints do not work before MySQL 5.0.74. As of 5.0.74, index hints work
is ignored with no warning and the index is still used.
SELECT
SELECT
result take into account the values retrieved by all of the
|
|
Syntax
SELECT
IGNORE INDEX (index_list)
USE INDEX (index_list)
SHOW
INDEX.
affect only which indexes are used when MySQL
clause. As of MySQL 5.0.40, the optional
GROUP BY
statements into a single result set.
SELECT
statement are used as the column names for the results
columns do not match, the types and lengths of the columns
1096
can be used to tell
shows that
EXPLAIN
but with the addition
PRIMARY KEY
IGNORE
statement should have
SELECT
statements. For
SELECT
would have been
SELECT
is
FOR JOIN

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents