• Mysql 5.1后支持哪些子分区


    前面提到了Mysql中的分区,现在我们来了解下子分区。大家都知道,分区有哪几类:range分区,List分区,hash分区,key分区四类,那么我们5.1后期能支持几种子分区呢?下面做个实验:

    range_hash复合分区:

    mysql> CREATE TABLE ts (id INT, purchased DATE)

    -> -> PARTITION BY RANGE(YEAR(purchased)) -> -> SUBPARTITION BY HASH(TO_DAYS(purchased)) -> -> SUBPARTITIONS 2 -> -> ( -> -> PARTITION p0 VALUES LESS THAN (1990), -> -> PARTITION p1 VALUES LESS THAN (2000), -> -> PARTITION p2 VALUES LESS THAN MAXVALUE -> -> );

    Query OK, 0 rows affected (0.11 sec)

    5.1.58是支持range_hash分区,我们再看下分区是怎么存储的

    mysql> insert into ts(id,purchased)values(1,'1989-12-26'); Query OK, 1 row affected (0.20 sec)

    mysql> select table_name,partition_name ,table_rows

    -> from information_schema.partitions -> where table_name='ts';

    table_name partition_name table_rows
    ts p0 0
    ts p0 1
    ts p1 0
    ts p1 0
    ts p2 0
    ts p2 0


    6 rows in set (0.14 sec)

    mysql> insert into ts(id,purchased)values(1,'2001-12-26'); Query OK, 1 row affected (0.00 sec)

    mysql> select table_name,partition_name ,table_rows from information_schema.partitions where table_name='ts';

    table_name partition_name table_rows
    ts p0 0
    ts p0 1
    ts p1 0
    ts p1 0
    ts p2 1
    ts p2 0


    6 rows in set (0.01 sec)

    mysql> insert into ts(id,purchased)values(1,'1989-2-26'); Query OK, 1 row affected (0.01 sec)

    mysql> select table_name,partition_name ,table_rows from information_schema.partitions where table_name='ts'; +------------+----------------+------------+

    table_name partition_name table_rows
    ts p0 1
    ts p0 1
    ts p1 0
    ts p1 0
    ts p2 1
    ts p2 0

    上面介绍的是range_hash复合分区及其存储情况,下面我们来看下支不支持list_hash复合分区

    mysql> CREATE TABLE tst (id INT, purchased DATE)

    -> -> PARTITION BY list(id) -> -> SUBPARTITION BY HASH(year(purchased)) -> -> SUBPARTITIONS 2 -> -> ( -> -> PARTITION p0 VALUES IN (1, 3, 5), -> -> PARTITION p1 VALUES IN (2, 4, 6) -> -> );


    Query OK, 0 rows affected (0.05 sec)

    mysql> insert into tst(id,purchased)values(4,'2000-2-26'); Query OK, 1 row affected (0.00 sec)

    mysql> select table_name,partition_name ,table_rows from information_schema.partitions where table_name='tst';

    table_name partition_name table_rows
    tst p0 0
    tst p0 0
    tst p1 1
    tst p1 0


    4 rows in set (0.00 sec)

    mysql> insert into tst(id,purchased)values(5,'2001-2-26'); Query OK, 1 row affected (0.00 sec)

    mysql> select table_name,partition_name ,table_rows from information_schema.partitions where table_name='tst';

    table_name partition_name table_rows
    tst p0 0
    tst p0 1
    tst p1 1
    tst p1 0


    4 rows in set (0.00 sec)

    mysql> insert into tst(id,purchased)values(5,'2002-2-26'); Query OK, 1 row affected (0.00 sec)

    mysql> select table_name,partition_name ,table_rows from information_schema.partitions where table_name='tst';

    table_name partition_name table_rows
    tst p0 1
    tst p0 1
    tst p1 1
    tst p1 0


    4 rows in set (0.00 sec)

    mysql> insert into tst(id,purchased)values(1,'2002-2-26'); Query OK, 1 row affected (0.00 sec)

    mysql> select table_name,partition_name ,table_rows from information_schema.partitions where table_name='tst';

    table_name partition_name table_rows
    tst p0 2
    tst p0 1
    tst p1 1
    tst p1 0

    4 rows in set (0.00 sec)

    mysql> insert into tst(id,purchased)values(2,'2002-2-26'); Query OK, 1 row affected (0.00 sec)

    mysql> select table_name,partition_name ,table_rows from information_schema.partitions where table_name='tst';

    table_name partition_name table_rows
    tst p0 2
    tst p0 1
    tst p1 2
    tst p1 0

    5.1暂时不支持list_range复合分区

    转载 http://xuebinbin212.blog.163.com/blog/static/112167376201111294221100/

  • 相关阅读:
    gcc 编译器常用的命令行参数一览
    linux下源代码分析和阅读工具比较
    Linux系统——C/C++开发工具及环境搭建
    GDB调试——经验总结
    gdb调试的艺术——Debug技巧
    命令__cp、scp(Secure Copy)
    常用shell脚本命令
    命令__查找、替换、删除
    UltraEdit 删除空行
    命令__shell数字-字符串比较
  • 原文地址:https://www.cnblogs.com/future2012lg/p/2991054.html
Copyright © 2020-2023  润新知