Mysql 分区处理NULL的得方式
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 分区处理NULL的得方式的更多相关文章
- mysql分区
<?php /* 分区 目录 18.1. MySQL中的分区概述 18.2. 分区类型 18.2.1. RANGE分区 18.2.2. LIST分区 18.2.3. HASH分区 18.2.4. ...
- 17.Mysql分区
17.Mysql分区分区是指根据一定的规则把一个表分解成多个部分,逻辑上仍是一张表,实际上由多个物理分区对象组成.分区对于应用是完全透明的,不影响业务逻辑和SQL编写.分区的优点: 可以存储更多的数据 ...
- mysql分区 详解
第18章:分区 目录 18.1. MySQL中的分区概述 18.2. 分区类型 18.2.1. RANGE分区 18.2.2. LIST分区 18.2.3. HASH分区 18.2.4. KEY分区 ...
- 第18章:MYSQL分区
第18章:分区 目录 18.1. MySQL中的分区概述 18.2. 分区类型 18.2.1. RANGE分区 18.2.2. LIST分区 18.2.3. HASH分区 18.2.4. KEY分区 ...
- MySQL分区 (分区介绍与实际使用)
分区介绍: 一.什么是分区? 所谓分区,就是将一个表分成多个区块进行操作和保存,从而降低每次操作的数据,提高性能.而对于应用来说则是透明的,从逻辑上看只有一张表,但在物理上这个表可能是由多个物理分区组 ...
- 十五、mysql 分区之 分区管理
1.mysql分区处理分区字段NULL值的方式 1.range分区null被当作最小值处理 2.list分区null值必须被枚举出来,否则将出错 3.hash/key分区 null值当作0处理 2.R ...
- mysql分区功能(三个文件储存一张表)(分区作用)(分区方式)
mysql分区功能(三个文件储存一张表)(分区作用)(分区方式) 一.总结 1.mysql数据表的存储方式(三个文件储存一张表): 一张表主要对应着三个文件,一个是frm存放表结构的,一个是myd存放 ...
- MySQL分区总结
MySQL支持RANGE,LIST,HASH和KEY四种分区.其中,每个分区又都有一种特殊的类型.对于RANGE分区,有RANGE COLUMNS分区.对于LIST分区,有LIST COLUMNS分区 ...
- mysql分区研究
表分区学习 1. 概述 1.1. 优点: l 将表分区比一个表在单个磁盘或者文件系统存储能够存储更多数据 l 可以通过drop分区删除无用数据,也可以通过增加分区添加数据 l 查询可以通过分区裁剪进行 ...
随机推荐
- 什么时候该用NoSQL?
: 杂谈 NoSQL这两年越来越热,尤其是大型互联网公司非常热衷这门技术.根据笔者的经验,并不是任何场景,NoSQL都要优于关系型数据库.下面我们来具体聊聊,什么时候使用NoSQL比较给力: 1) ...
- Windows服务二:测试新建的服务、调试Windows服务
一.测试Windows服务 为了使Windows服务程序能够正常运行,我们需要像创建一般应用程序那样为它创建一个程序的入口点.像其他应用程序一样,Windows服务也是在Program.cs的Main ...
- JSP(include指令)页面
<%@ page language= "java" contentType="text/html;charset=UTF-8" %><html ...
- selenium—八种定位方法
find_element_by_id() find_element_by_name() find_element_by_class_name() find_element_by_tag_name() ...
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
控制台包空指针后跟这个异常,是因为控制层调用service时的失败,无法读到sql,问题在于controller在引入的service没有自动装配,在引入多个service时,每个service都要自 ...
- js中的call与apply深入浅出
首先明确call()与apply()最大的区别,除了名字不同以外,就是参数不一样,call的参数需要一一列出,apply的第二个及其以后的参数需要组成一个数组传进来. 这两个函数的调用者不是对象,而是 ...
- Chrome & Linux font
1 $ sudo apt-get install texlive-full # 较大 2 $ mkdir -p ~/.fonts 3 下载这个win7字体包解压后放到~/.fonts下 4 $ sud ...
- 2016CCPC 合肥--最大公约数//每一年通向它的路上,多少人折戟沉沙,多少人功败垂成,有人一战成名,有人从头再来。
有这样一个有关最大公约数的函数:函数 f(x, y): { c=0 当 y>0: { c +=1 t = x % y x = y y = t } 返回 c * x * x} 给出三个正整数n,m ...
- qt5中QPrinter的使用兼容性问题
qt5与qt4在QPrinter中使用的不同点如下: 在.pro文件中加入如下语句:
- C# 动软生成器对应的Access数据库操作类DbHelperOleDb
using System;using System.Collections;using System.Collections.Specialized;using System.Data;using S ...