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:
- renewal DATE
- )
- );
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:
- renewal DATE
- )
- '2010-02-04', '2010-02-05', '2010-02-06', '2010-02-07'),
- '2010-02-11', '2010-02-12', '2010-02-13', '2010-02-14'),
- '2010-02-18', '2010-02-19', '2010-02-20', '2010-02-21'),
- '2010-02-25', '2010-02-26', '2010-02-27', '2010-02-28')
- );
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:
- renewal DATE
- )
- );
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.
Traduction non disponible
Le manuel MySQL n'est pas encore traduit en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Document créé le 26/06/2006, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/mysql-rf-partitioning-columns-list.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.