Mysql 分区处理NULL值的方式
2016-08-09 22:25
204 查看
MySQL分区处理NULL值的方式
一般情况下,MySQL的分区把NULL当做零值,或者一个最小值进行处理对于range分区
create table test_null( id int ) partition by range(id)( partition p0 values less than (-6), partition p1 values less than (0), partition p2 values less than (1), partition p3 values less than MAXVALUE ); mysql> insert into test_null values(null); Query OK, 1 row affected (0.01 sec) mysql> select -> partition_name part, -> partition_expression expr, -> partition_description descr, -> table_rows -> from information_schema.partitions where -> table_schema = schema() -> and table_name='test_null'; +------+------+----------+------------+ | part | expr | descr | table_rows | +------+------+----------+------------+ | p0 | id | -6 | 1 | | p1 | id | 0 | 0 | | p2 | id | 1 | 0 | | p3 | id | MAXVALUE | 0 | +------+------+----------+------------+ 4 rows in set (0.00 sec)
对于list分区
当分区定义不包含NULL值是,会报错
create table list_null( id int ) partition by list(id)( partition p1 values in (0), partition p2 values in (1) ); mysql> insert into list_null values(null); ERROR 1526 (HY000): Table has no partition for value NULL
当分区定义包含NULL时
create table list_null_1( id int ) partition by list(id)( partition p1 values in (0), partition p2 values in (1), partition p3 values in (null) ); mysql> insert into list_null_1 values(null); Query OK, 1 row affected (0.01 sec) mysql> select -> partition_name part, -> partition_expression expr, -> partition_description descr, -> table_rows -> from information_schema.partitions where -> table_schema = schema() -> and table_name='list_null_1'; +------+------+-------+------------+ | part | expr | descr | table_rows | +------+------+-------+------------+ | p1 | id | 0 | 0 | | p2 | id | 1 | 0 | | p3 | id | NULL | 1 | +------+------+-------+------------+ 3 rows in set (0.00 sec)
对于Hash分区和key分区
create table hash_null( id int ) partition by hash(id) partitions 2; mysql> insert into hash_null values(null); Query OK, 1 row affected (0.00 sec) mysql> select -> partition_name part, -> partition_expression expr, -> partition_description descr, -> table_rows -> from information_schema.partitions where -> table_schema = schema() -> and table_name='hash_null'; +------+------+-------+------------+ | part | expr | descr | table_rows | +------+------+-------+------------+ | p0 | id | NULL | 1 | | p1 | id | NULL | 0 | +------+------+-------+------------+ 2 rows in set (0.00 sec) 对于Key分区 create table key_null( id int ) partition by key(id) partitions 2; mysql> select -> partition_name part, -> partition_expression expr, -> partition_description descr, -> table_rows -> from information_schema.partitions where -> table_schema = schema() -> and table_name='key_null'; +------+------+-------+------------+ | part | expr | descr | table_rows | +------+------+-------+------------+ | p0 | `id` | NULL | 1 | | p1 | `id` | NULL | 0 | +------+------+-------+------------+
相关文章推荐
- MySQL 分区表 partition线上修改分区字段,后续进一步学习partition (2) --> 子分区以及对录入Null值的处理情况.
- MySQL 分区表 partition线上修改分区字段,后续进一步学习partition (2) --> 子分区以及对录入Null值的处理情况.
- mysql 存储过程 参数 没有数组的处理方式
- MySQL安装-处理RPM方式安装mysql-5.5.25报错
- MySQL锁机制详解及死锁处理方式
- mysql忘记密码的处理方式(整理非原创)
- 关于 Unix 系统下 DB2 分区内并行性方式对应用程序的处理
- mysql忘记密码的处理方式总结
- 大数据文件导入MySql处理方式
- Mysql整数运算NULL值处理注意点
- ORM写mysql(最终处理方式)
- mysql group by 处理方式的异同
- MYSQL 存储过程 多表更新异常捕捉和异常处理方式
- MySQL重复主键处理方式
- MySQL日期字符串转换成NULL值的异常处理
- otl通过ODBC方式操作mysql, blob类型的处理
- Linux c 连接处理MYSQL (API方式)
- mysql 中外键处理的三种方式
- Mysql中使用聚合函数对null值的处理
- MYSQL UPDATE不支持子查询的处理方式