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

C.10.4 Limits on Table Column Count and Row Size

Column Count Limits

MySQL has hard limit of 4096 columns per table, but the effective maximum may be less for a given table. The exact column limit depends on several factors:

Inhaltsverzeichnis Haut

Row Size Limits

The maximum row size for a given table is determined by several factors:

  • The internal representation of a MySQL table has a maximum row size limit of 65,535 bytes, even if the storage engine is capable of supporting larger rows. BLOB and TEXT columns only contribute 9 to 12 bytes toward the row size limit because their contents are stored separately from the rest of the row.

  • The maximum row size for an InnoDB table, which applies to data stored locally within a database page, is slightly less than half a page for 4KB, 8KB, 16KB, and 32KB innodb_page_size settings. For example, the maximum row size is slightly less than 8KB for the default 16KB InnoDB page size. For 64KB pages, the maximum row size is slightly less than 16KB. See Section 15.6.1.6, “Limits on InnoDB Tables”.

    If a row containing variable-length columns exceeds the InnoDB maximum row size, InnoDB selects variable-length columns for external off-page storage until the row fits within the InnoDB row size limit. The amount of data stored locally for variable-length columns that are stored off-page differs by row format. For more information, see Section 15.10, “InnoDB Row Formats”.

  • Different storage formats use different amounts of page header and trailer data, which affects the amount of storage available for rows.

Inhaltsverzeichnis Haut

Row Size Limit Examples
  • The MySQL maximum row size limit of 65,535 bytes is demonstrated in the following InnoDB and MyISAM examples. The limit is enforced regardless of storage engine, even though the storage engine may be capable of supporting larger rows.

    1. mysql> CREATE TABLE t (a VARCHAR(10000), b VARCHAR(10000),
    2.        c VARCHAR(10000), d VARCHAR(10000), e VARCHAR(10000),
    3.        f VARCHAR(10000), g VARCHAR(6000)) ENGINE=InnoDB CHARACTER SET latin1;
    4. ERROR 1118 (42000): Row size too large. The maximum row size for the used
    5. table type, not counting BLOBs, is 65535. This includes storage overhead,
    6. check the manual. You have to change some columns to TEXT or BLOBs
    1. mysql> CREATE TABLE t (a VARCHAR(10000), b VARCHAR(10000),
    2.        c VARCHAR(10000), d VARCHAR(10000), e VARCHAR(10000),
    3.        f VARCHAR(10000), g VARCHAR(6000)) ENGINE=MyISAM CHARACTER SET latin1;
    4. ERROR 1118 (42000): Row size too large. The maximum row size for the used
    5. table type, not counting BLOBs, is 65535. This includes storage overhead,
    6. check the manual. You have to change some columns to TEXT or BLOBs

    In the following MyISAM example, changing a column to TEXT avoids the 65,535-byte row size limit and permits the operation to succeed because BLOB and TEXT columns only contribute 9 to 12 bytes toward the row size.

    1. mysql> CREATE TABLE t (a VARCHAR(10000), b VARCHAR(10000),
    2.        c VARCHAR(10000), d VARCHAR(10000), e VARCHAR(10000),
    3.        f VARCHAR(10000), g TEXT(6000)) ENGINE=MyISAM CHARACTER SET latin1;
    4. Query OK, 0 rows affected (0.02 sec)

    The operation succeeds for an InnoDB table because changing a column to TEXT avoids the MySQL 65,535-byte row size limit, and InnoDB off-page storage of variable-length columns avoids the InnoDB row size limit.

    1. mysql> CREATE TABLE t (a VARCHAR(10000), b VARCHAR(10000),
    2.        c VARCHAR(10000), d VARCHAR(10000), e VARCHAR(10000),
    3.        f VARCHAR(10000), g TEXT(6000)) ENGINE=InnoDB CHARACTER SET latin1;
    4. Query OK, 0 rows affected (0.02 sec)
  • Storage for variable-length columns includes length bytes, which are counted toward the row size. For example, a VARCHAR(255) CHARACTER SET utf8mb3 column takes two bytes to store the length of the value, so each value can take up to 767 bytes.

    The statement to create table t1 succeeds because the columns require 32,765 + 2 bytes and 32,766 + 2 bytes, which falls within the maximum row size of 65,535 bytes:

    1. mysql> CREATE TABLE t1
    2.        (c1 VARCHAR(32765) NOT NULL, c2 VARCHAR(32766) NOT NULL)
    3.        ENGINE = InnoDB CHARACTER SET latin1;
    4. Query OK, 0 rows affected (0.02 sec)

    The statement to create table t2 fails because, although the column length is within the maximum length of 65,535 bytes, two additional bytes are required to record the length, which causes the row size to exceed 65,535 bytes:

    1. mysql> CREATE TABLE t2
    2.        (c1 VARCHAR(65535) NOT NULL)
    3.        ENGINE = InnoDB CHARACTER SET latin1;
    4. ERROR 1118 (42000): Row size too large. The maximum row size for the used
    5. table type, not counting BLOBs, is 65535. This includes storage overhead,
    6. check the manual. You have to change some columns to TEXT or BLOBs

    Reducing the column length to 65,533 or less permits the statement to succeed.

    1. mysql> CREATE TABLE t2
    2.        (c1 VARCHAR(65533) NOT NULL)
    3.        ENGINE = InnoDB CHARACTER SET latin1;
    4. Query OK, 0 rows affected (0.01 sec)
  • For MyISAM tables, NULL columns require additional space in the row to record whether their values are NULL. Each NULL column takes one bit extra, rounded up to the nearest byte.

    The statement to create table t3 fails because MyISAM requires space for NULL columns in addition to the space required for variable-length column length bytes, causing the row size to exceed 65,535 bytes:

    1. mysql> CREATE TABLE t3
    2.        (c1 VARCHAR(32765) NULL, c2 VARCHAR(32766) NULL)
    3.        ENGINE = MyISAM CHARACTER SET latin1;
    4. ERROR 1118 (42000): Row size too large. The maximum row size for the used
    5. table type, not counting BLOBs, is 65535. This includes storage overhead,
    6. check the manual. You have to change some columns to TEXT or BLOBs

    For information about InnoDB NULL column storage, see Section 15.10, “InnoDB Row Formats”.

  • InnoDB restricts row size (for data stored locally within the database page) to slightly less than half a database page for 4KB, 8KB, 16KB, and 32KB innodb_page_size settings, and to slightly less than 16KB for 64KB pages.

    The statement to create table t4 fails because the defined columns exceed the row size limit for a 16KB InnoDB page.

    1. mysql> CREATE TABLE t4 (
    2.        c1 CHAR(255),c2 CHAR(255),c3 CHAR(255),
    3.        c4 CHAR(255),c5 CHAR(255),c6 CHAR(255),
    4.        c7 CHAR(255),c8 CHAR(255),c9 CHAR(255),
    5.        c10 CHAR(255),c11 CHAR(255),c12 CHAR(255),
    6.        c13 CHAR(255),c14 CHAR(255),c15 CHAR(255),
    7.        c16 CHAR(255),c17 CHAR(255),c18 CHAR(255),
    8.        c19 CHAR(255),c20 CHAR(255),c21 CHAR(255),
    9.        c22 CHAR(255),c23 CHAR(255),c24 CHAR(255),
    10.        c25 CHAR(255),c26 CHAR(255),c27 CHAR(255),
    11.        c28 CHAR(255),c29 CHAR(255),c30 CHAR(255),
    12.        c31 CHAR(255),c32 CHAR(255),c33 CHAR(255)
    13.        ) ENGINE=InnoDB ROW_FORMAT=DYNAMIC DEFAULT CHARSET latin1;
    14. ERROR 1118 (42000): Row size too large (> 8126). Changing some columns to TEXT or BLOB may help.
    15. In current row format, BLOB prefix of 0 bytes is stored inline.

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-column-count-limit.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