Rechercher dans le manuel MySQL
23.3 Partition Management
[+/-]
There are a number of ways using SQL statements to modify
partitioned tables; it is possible to add, drop, redefine, merge,
or split existing partitions using the partitioning extensions to
the
ALTER
TABLE
statement. There are also ways to obtain
information about partitioned tables and partitions. We discuss
these topics in the sections that follow.
For information about partition management in tables partitioned by
RANGE
orLIST
, see Section 23.3.1, “Management of RANGE and LIST Partitions”.For a discussion of managing
HASH
andKEY
partitions, see Section 23.3.2, “Management of HASH and KEY Partitions”.See Section 23.3.5, “Obtaining Information About Partitions”, for a discussion of mechanisms provided in MySQL 8.0 for obtaining information about partitioned tables and partitions.
For a discussion of performing maintenance operations on partitions, see Section 23.3.4, “Maintenance of Partitions”.
All partitions of a partitioned table must have the same number of subpartitions; it is not possible to change the subpartitioning once the table has been created.
To change a table's partitioning scheme, it is necessary only
to use the
ALTER
TABLE
statement with a
partition_options
option, which has the
same syntax as that as used with CREATE
TABLE
for creating a partitioned table; this option
(also) always begins with the keywords PARTITION
BY
. Suppose that the following
CREATE TABLE
statement was used to
create a table that is partitioned by range:
- );
To repartition this table so that it is partitioned by key into
two partitions using the id
column value as the
basis for the key, you can use this statement:
This has the same effect on the structure of the table as dropping
the table and re-creating it using CREATE TABLE trb3
PARTITION BY KEY(id) PARTITIONS 2;
.
ALTER TABLE ... ENGINE = ...
changes only the
storage engine used by the table, and leaves the table's
partitioning scheme intact. The statement succeeds only if the
target storage engine provides partitioning support. You can use
ALTER TABLE ... REMOVE PARTITIONING
to remove a
table's partitioning; see Section 13.1.9, “ALTER TABLE Syntax”.
Only a single PARTITION BY
, ADD
PARTITION
, DROP PARTITION
,
REORGANIZE PARTITION
, or COALESCE
PARTITION
clause can be used in a given
ALTER
TABLE
statement. If you (for example) wish to drop a
partition and reorganize a table's remaining partitions,
you must do so in two separate
ALTER
TABLE
statements (one using DROP
PARTITION
and then a second one using
REORGANIZE PARTITION
).
You can delete all rows from one or more selected partitions using
ALTER TABLE ...
TRUNCATE PARTITION
.
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-management.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.