参数 ora_input_emptystr_isnull 对于数据存储的影响
原生的PG 对于 '' 和 null 认为是不同值:空值 和不确定值;而oracle 认为二者都是不确定的值。KingbaseES 为了兼容Oracle,增加了参数ora_input_emptystr_isnull,用于控制 '' 和 null 的比较。
一、Oracle null and '' 比较
SQL> create table t1(id number,name varchar(9));
Table created.
SQL> insert into t1(id) values(1);
1 row created.
SQL> insert into t1 values(2,''); --注意,中间没有空格。有空格就不是null
1 row created.
SQL> insert into t1 values(3,null);
1 row created.
SQL> select * from t1 where name is null;
ID NAME
---------- ---------
1
2
3
SQL> select * from t1 where name='';
no rows selected
SQL> select length(name) from t1;
LENGTH(NAME)
------------
SQL>
可以看到,不管插入 null or '',Oracle 都看做 null。
二、KingbaseES
1、ora_input_emptystr_isnull=off
test=# show ora_input_emptystr_isnull;
ora_input_emptystr_isnull
---------------------------
off
(1 row)
test=# create table t1(id number,name varchar(9));
CREATE TABLE
test=# insert into t1(id) values(1);
INSERT 0 1
test=# insert into t1 values(2,'');
INSERT 0 1
test=# insert into t1 values(3,null);
INSERT 0 1
test=# select * from t1 where name is null;
id | name
----+------
1 |
3 |
(2 rows) test=# select * from t1 where name='';
id | name
----+------
2 |
(1 row) test=# select id,length(name) from t1;
id | length
---+--------
1 |
2 | 0
3 |
(3 rows)
结论:当ora_input_emptystr_isnull=off时,null 和 '' 实际不同的。
在数据插入后,将参数改成on,看下查询的不同结果:
test=# show ora_input_emptystr_isnull;
ora_input_emptystr_isnull
---------------------------
on
(1 row) test=# select * from t1 where name=''; --这个也没结果,这个数据“丢失“了
id | name
----+------
(0 rows) test=# select * from t1 where name is null;
id | name
----+------
1 |
3 |
(2 rows) test=# select id,length(name) from t1;
id | length
----+--------
1 |
2 | 0
3 |
(3 rows)
结论:当数据保存到数据库时,会根据参数ora_input_emptystr_isnull 保存为不同格式,后续的参数修改不影响已存储的数据。
2、ora_input_emptystr_isnull=on
test=# show ora_input_emptystr_isnull;
ora_input_emptystr_isnull
---------------------------
on
(1 row) test=# drop table t1;
DROP TABLE
test=# create table t1(id number,name varchar(9));
CREATE TABLE
test=# insert into t1(id) values(1);
INSERT 0 1
test=# insert into t1 values(2,'');
INSERT 0 1
test=# insert into t1 values(3,null);
INSERT 0 1
test=# select * from t1 where name='';
id | name
----+------
(0 rows) test=# select * from t1 where name is null;
id | name
----+------
1 |
2 |
3 |
(3 rows) test=# select id,length(name) from t1;
id | length
----+--------
1 |
2 |
3 |
(3 rows)
将参数改为off ,看下执行结果
test=# set ora_input_emptystr_isnull=off;
SET
test=# select * from t1 where name is null;
id | name
----+------
1 |
2 |
3 |
(3 rows) test=# select * from t1 where name='';
id | name
----+------
(0 rows)
结论:将参数改为off后,执行结果不变。
注意:由于参数 ora_input_emptystr_isnull不同设置,会修改实际的数据存储,为了保证数据不发生“丢失”,建议用户在系统初始化后就确定参数 ora_input_emptystr_isnull 的值,避免后续数据入库后再去修改参数。
参数 ora_input_emptystr_isnull 对于数据存储的影响的更多相关文章
- 讨论关于RAID以及RAID对于存储的影响
定义及作用 RAID是Redundent Array of Inexpensive Disks的缩写,直译为“廉价冗余磁盘阵列”,也简称为“磁盘阵列”.后来RAID中的字母I被改作了Independe ...
- Kafka session.timeout.ms heartbeat.interval.ms参数的区别以及对数据存储的一些思考
Kafka session.timeout.ms heartbeat.interval.ms参数的区别以及对数据存储的一些思考 在计算机世界中经常需要与数据打交道,这也是我们戏称CURD工程师的原因之 ...
- 数据存储之 SharedPreference 共享参数 (转)
在上一讲中,我们学习了如何将数据存储在SD卡中[数据存储之File文件存储 [即SD卡的写入与读取]],这是一种存储方式,这一讲我们来学习一下使用SharedPreferences存储数据. ...
- android 开发-数据存储之共享参数
android提供5中数据存储方式 数据存储之共享参数 内部存储 扩展存储 数据库存储 网络存储 而共享存储提供一种可以让用户存储保存一些持久化键值对在文件中,以供其他应用对这些共享参数进行调用.共 ...
- PCTUSED和PCTFREE对数据操作的影响
1概念理解 首先PCTUSED和PCTFREE都是针对数据块的存储属性,单位都是%.其中PCTFREE决定了数据块什么时候从free list中移除,系统就不可以再往该数据块中插入数据,对于数据块中已 ...
- 智能合约语言 Solidity 教程系列4 - 数据存储位置分析
写在前面 Solidity 是以太坊智能合约编程语言,阅读本文前,你应该对以太坊.智能合约有所了解, 如果你还不了解,建议你先看以太坊是什么 这部分的内容官方英文文档讲的不是很透,因此我在参考Soli ...
- CSAPP-过程调用,数据存储,缓冲区溢出
程序编译: 1.预处理阶段: 1.文件包含:将#include扩展成文件正文 2.条件编译:根据#if和#ifdef将程序的某部分排除或者包含 3.宏展开:将出现宏引用的地方展开成相应的宏 2.编译阶 ...
- H5本地存储详细使用教程(localStorage + JSON数据存储应用框架)
一.Web Storage教程 1.概述: 对于Web Storage来说,实际上是Cookies存储的进化版.如果了解Cookie的人几乎一看Web Storage就会用,如果你从来没用过没了解过C ...
- Hashtable数据存储结构-遍历规则,Hash类型的复杂度为啥都是O(1)-源码分析
Hashtable 是一个很常见的数据结构类型,前段时间阿里的面试官说只要搞懂了HashTable,hashMap,HashSet,treeMap,treeSet这几个数据结构,阿里的数据结构面试没问 ...
- ubuntu14.04 rabbitmq安装与使用 --修改RabbitMQ数据存储位置
参考:https://blog.csdn.net/tianjiewang/article/details/58383062 说明: ubuntu14.04 rabiitmq 默认 安装路径 /va ...
随机推荐
- Swoole从入门到入土(7)——TCP服务器[大杂烩]
这一篇是异步风格的TCP服务器的最后一篇,主要的目的是疏理之前几篇没提到的一些比较有用的属性.配置.函数与事件,当然不是全部.如果想知道全部,请查看官网. 1.属性 Swoole\Server-> ...
- Oracle 10gR2新SQL提示——opt_param
[English] 搜索Internet 搜索 HelloDBABA 首页 English 中文 技术文档 文章 案例 产品及下载 产品 >> FyDB OraTracer FySafe ...
- win32 - 内存映射(CreateFileMapping)
目标:创建一个app,使用CreateToolhelp32Snapshot扫描所有的进程,并将进程的pid和exe名字映射到内存中,再在另一个app中使用OpenFileMapping打开该映射读取相 ...
- flutter打包android的一些配置修改(解决白屏,视频闪退)
1.打包后视频播放闪退 视频播放器选择了flutter_tencentplayer(https://github.com/qq326646683/flutter_tencentplayer) 解决:不 ...
- 优雅使用前端枚举Enum,符合国标的那种!
01.什么是枚举Enum? 枚举Enum是在多种语言中都有的一种数据类型,用于表示一组特定相关的常量数据集合,如性别(男.女).数据状态(可用.禁用).垂直对齐(顶端.居中.底部).星期等.特点是数据 ...
- zookeeper运行时dos窗口一闪而过
错误:从官网下载zookeeper解压到本地之后,鼠标双击运行zkServer.cmd文件,dos窗口一闪而过,看不到错误原因: 解决方法:通过dos窗口执行zkServer.cmd文件,对应的错误信 ...
- 【LeetCode动态规划#16】矩阵的最小路径和、三角形的最小路径和
矩阵的最小路径和 给定一个包含非负整数的 *m* x *n* 网格 grid ,请找出一条从左上角到右下角的路径,使得路径上的数字总和为最小. 说明:一个机器人每次只能向下或者向右移动一步. 示例 1 ...
- SpringCloud使用Kafka消费者
目录 POM文件配置 创建kafka配置 系统配置信息 启动入口 POM文件配置 <project xmlns="http://maven.apache.org/POM/4.0.0&q ...
- 【Azure Redis 缓存 Azure Cache For Redis】Redis支持的版本及不同版本迁移风险
问题描述 1. Azure Redis缓存支持的版本包括4.0以及6.0(预览) 这种情形下,可以使用PaaS服务提供的 Azure Redis 缓存(4.0版本).Azure Redis对6.0的支 ...
- 使用 MyBatis 操作 Nebula Graph 的实践
本文首发于 Nebula Graph Community 公众号 我最近注意到很多同学对于 ORM 框架的需求比较迫切,而且有热心的同学已经捐赠了自己开发的项目,Nebula 社区也在 working ...