Keine Cache-Version

Caching deaktiviert Standardeinstellung für diese Seite:aktiviert (code DEF204)
Wenn die Anzeige zu langsam ist, können Sie den Benutzermodus deaktivieren, um die zwischengespeicherte Version anzuzeigen.

Rechercher dans le manuel MySQL

13.7.6.22 SHOW INDEX Syntax

  1. SHOW [EXTENDED] {INDEX | INDEXES | KEYS}
  2.     {FROM | IN} tbl_name
  3.     [{FROM | IN} db_name]
  4.     [WHERE expr]

SHOW INDEX returns table index information. The format resembles that of the SQLStatistics call in ODBC. This statement requires some privilege for any column in the table.

  1. mysql> SHOW INDEX FROM City\G
  2. *************************** 1. row ***************************
  3.         Table: city
  4.    Non_unique: 0
  5.      Key_name: PRIMARY
  6.  Seq_in_index: 1
  7.   Column_name: ID
  8.     Collation: A
  9.   Cardinality: 4188
  10.      Sub_part: NULL
  11.        Packed: NULL
  12.          Null:
  13.    Index_type: BTREE
  14.       Comment:
  15. Index_comment:
  16.       Visible: YES
  17.    Expression: NULL
  18. *************************** 2. row ***************************
  19.         Table: city
  20.    Non_unique: 1
  21.      Key_name: CountryCode
  22.  Seq_in_index: 1
  23.   Column_name: CountryCode
  24.     Collation: A
  25.   Cardinality: 232
  26.      Sub_part: NULL
  27.        Packed: NULL
  28.          Null:
  29.    Index_type: BTREE
  30.       Comment:
  31. Index_comment:
  32.       Visible: YES
  33.    Expression: NULL

An alternative to tbl_name FROM db_name syntax is db_name.tbl_name. These two statements are equivalent:

  1. SHOW INDEX FROM mytable FROM mydb;
  2. SHOW INDEX FROM mydb.mytable;

The optional EXTENDED keyword causes the output to include information about hidden indexes that MySQL uses internally and are not accessible by users.

The WHERE clause can be given to select rows using more general conditions, as discussed in Section 25.42, “Extensions to SHOW Statements”.

SHOW INDEX returns the following fields:

  • Table

    The name of the table.

  • Non_unique

    0 if the index cannot contain duplicates, 1 if it can.

  • Key_name

    The name of the index. If the index is the primary key, the name is always PRIMARY.

  • Seq_in_index

    The column sequence number in the index, starting with 1.

  • Column_name

    The column name. See also the description for the Expression column.

  • Collation

    How the column is sorted in the index. This can have values A (ascending), D (descending), or NULL (not sorted).

  • Cardinality

    An estimate of the number of unique values in the index. To update this number, run ANALYZE TABLE or (for MyISAM tables) myisamchk -a.

    Cardinality is counted based on statistics stored as integers, so the value is not necessarily exact even for small tables. The higher the cardinality, the greater the chance that MySQL uses the index when doing joins.

  • Sub_part

    The index prefix. That is, the number of indexed characters if the column is only partly indexed, NULL if the entire column is indexed.

    Note

    Prefix limits are measured in bytes. However, prefix lengths for index specifications in CREATE TABLE, ALTER TABLE, and CREATE INDEX statements are interpreted as number of characters for nonbinary string types (CHAR, VARCHAR, TEXT) and number of bytes for binary string types (BINARY, VARBINARY, BLOB). Take this into account when specifying a prefix length for a nonbinary string column that uses a multibyte character set.

    For additional information about index prefixes, see Section 8.3.5, “Column Indexes”, and Section 13.1.15, “CREATE INDEX Syntax”.

  • Packed

    Indicates how the key is packed. NULL if it is not.

  • Null

    Contains YES if the column may contain NULL values and '' if not.

  • Index_type

    The index method used (BTREE, FULLTEXT, HASH, RTREE).

  • Comment

    Information about the index not described in its own column, such as disabled if the index is disabled.

  • Index_comment

    Any comment provided for the index with a COMMENT attribute when the index was created.

  • Visible

    Whether the index is visible to the optimizer. See Section 8.3.12, “Invisible Indexes”.

  • Expression

    MySQL 8.0.13 and higher supports functional key parts (see Functional Key Parts), which affects both the Column_name and Expression columns:

    • For a nonfunctional key part, Column_name indicates the column indexed by the key part and Expression is NULL.

    • For a functional key part, Column_name column is NULL and Expression indicates the expression for the key part.

Information about table indexes is also available from the INFORMATION_SCHEMA STATISTICS table. See Section 25.26, “The INFORMATION_SCHEMA STATISTICS Table”. The extended information about hidden indexes is available only using SHOW EXTENDED INDEX; it cannot be obtained from the STATISTICS table.

You can list a table's indexes with the mysqlshow -k db_name tbl_name command.


Suchen Sie im MySQL-Handbuch

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 26/06/2006, zuletzt geändert 26/10/2018
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/mysql-rf-show-index.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:en Manuel MySQL : https://dev.mysql.com/

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.

Inhaltsverzeichnis Haut