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

23.2.3.2 LIST COLUMNS partitioning

MySQL 8.0 provides support for LIST COLUMNS partitioning. This is a variant of LIST partitioning that enables the use of multiple columns as partition keys, and for columns of data types other than integer types to be used as partitioning columns; you can use string types, DATE, and DATETIME columns. (For more information about permitted data types for COLUMNS partitioning columns, see Section 23.2.3, “COLUMNS Partitioning”.)

Suppose that you have a business that has customers in 12 cities which, for sales and marketing purposes, you organize into 4 regions of 3 cities each as shown in the following table:

Region Cities
1 Oskarshamn, Högsby, Mönsterås
2 Vimmerby, Hultsfred, Västervik
3 Nässjö, Eksjö, Vetlanda
4 Uppvidinge, Alvesta, Växjo

With LIST COLUMNS partitioning, you can create a table for customer data that assigns a row to any of 4 partitions corresponding to these regions based on the name of the city where a customer resides, as shown here:

  1. CREATE TABLE customers_1 (
  2.     first_name VARCHAR(25),
  3.     last_name VARCHAR(25),
  4.     street_1 VARCHAR(30),
  5.     street_2 VARCHAR(30),
  6.     city VARCHAR(15),
  7.     renewal DATE
  8. )
  9. PARTITION BY LIST COLUMNS(city) (
  10.     PARTITION pRegion_1 VALUES IN('Oskarshamn', 'Högsby', 'Mönsterås'),
  11.     PARTITION pRegion_2 VALUES IN('Vimmerby', 'Hultsfred', 'Västervik'),
  12.     PARTITION pRegion_3 VALUES IN('Nässjö', 'Eksjö', 'Vetlanda'),
  13.     PARTITION pRegion_4 VALUES IN('Uppvidinge', 'Alvesta', 'Växjo')
  14. );

As with partitioning by RANGE COLUMNS, you do not need to use expressions in the COLUMNS() clause to convert column values into integers. (In fact, the use of expressions other than column names is not permitted with COLUMNS().)

It is also possible to use DATE and DATETIME columns, as shown in the following example that uses the same name and columns as the customers_1 table shown previously, but employs LIST COLUMNS partitioning based on the renewal column to store rows in one of 4 partitions depending on the week in February 2010 the customer's account is scheduled to renew:

  1. CREATE TABLE customers_2 (
  2.     first_name VARCHAR(25),
  3.     last_name VARCHAR(25),
  4.     street_1 VARCHAR(30),
  5.     street_2 VARCHAR(30),
  6.     city VARCHAR(15),
  7.     renewal DATE
  8. )
  9. PARTITION BY LIST COLUMNS(renewal) (
  10.     PARTITION pWeek_1 VALUES IN('2010-02-01', '2010-02-02', '2010-02-03',
  11.         '2010-02-04', '2010-02-05', '2010-02-06', '2010-02-07'),
  12.     PARTITION pWeek_2 VALUES IN('2010-02-08', '2010-02-09', '2010-02-10',
  13.         '2010-02-11', '2010-02-12', '2010-02-13', '2010-02-14'),
  14.     PARTITION pWeek_3 VALUES IN('2010-02-15', '2010-02-16', '2010-02-17',
  15.         '2010-02-18', '2010-02-19', '2010-02-20', '2010-02-21'),
  16.     PARTITION pWeek_4 VALUES IN('2010-02-22', '2010-02-23', '2010-02-24',
  17.         '2010-02-25', '2010-02-26', '2010-02-27', '2010-02-28')
  18. );

This works, but becomes cumbersome to define and maintain if the number of dates involved grows very large; in such cases, it is usually more practical to employ RANGE or RANGE COLUMNS partitioning instead. In this case, since the column we wish to use as the partitioning key is a DATE column, we use RANGE COLUMNS partitioning, as shown here:

  1. CREATE TABLE customers_3 (
  2.     first_name VARCHAR(25),
  3.     last_name VARCHAR(25),
  4.     street_1 VARCHAR(30),
  5.     street_2 VARCHAR(30),
  6.     city VARCHAR(15),
  7.     renewal DATE
  8. )
  9. PARTITION BY RANGE COLUMNS(renewal) (
  10.     PARTITION pWeek_1 VALUES LESS THAN('2010-02-09'),
  11.     PARTITION pWeek_2 VALUES LESS THAN('2010-02-15'),
  12.     PARTITION pWeek_3 VALUES LESS THAN('2010-02-22'),
  13.     PARTITION pWeek_4 VALUES LESS THAN('2010-03-01')
  14. );

See Section 23.2.3.1, “RANGE COLUMNS partitioning”, for more information.

In addition (as with RANGE COLUMNS partitioning), you can use multiple columns in the COLUMNS() clause.

See Section 13.1.20, “CREATE TABLE Syntax”, for additional information about PARTITION BY LIST COLUMNS() syntax.


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-partitioning-columns-list.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