MySQL supports only horizontal partitioning. In MySQL, there are six types of partitioning, one of them is List partitioning, which is going to be explained in this article with the help of an example.
What is the List Partitioning in MySQL
In MySQL, List partitioning is used similar to range partitioning, the difference is that, in range partitioning, we have to define the range on the basis of which it partitioned the data whereas, in the List partition, it partitions the data on the basis of pre-defined information, to understand this by creating a table of the products_data and we will partition the data on the basis of the products and create a table using the command:
To insert values in the newly created table, run the command:
The data can be displayed in the table, products_data:
To insert a value against the list partition which is not predefined and let us see what happened:
In the above output, we can see that the error has been displayed as no partition has been defined for “77” so it generated an error for the value inserted against the partition “77”, which means in the List partition, data is inserted only against the pre-defined partitions.
It is important to note here that in the List partition while inserting the values, the table will allow only those values which will fulfill the definition of the List partition.
Conclusion
Partitioning is a process by which tables of MySQL are divided into further tables and this makes it easy for the user to manage the data as well as for the processor of the computer to execute the queries. List partitioning is the type of partitioning in which the partitions are pre-defined and the data inserted in the tables according to these pre-defined partitions. In this write-up, we explained the List partition with the help of an example and also demonstrated that if the value is inserted against the definition of List partition, it does not accept it and generates the error.