原生的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 对于数据存储的影响的更多相关文章

  1. 讨论关于RAID以及RAID对于存储的影响

    定义及作用 RAID是Redundent Array of Inexpensive Disks的缩写,直译为“廉价冗余磁盘阵列”,也简称为“磁盘阵列”.后来RAID中的字母I被改作了Independe ...

  2. Kafka session.timeout.ms heartbeat.interval.ms参数的区别以及对数据存储的一些思考

    Kafka session.timeout.ms heartbeat.interval.ms参数的区别以及对数据存储的一些思考 在计算机世界中经常需要与数据打交道,这也是我们戏称CURD工程师的原因之 ...

  3. 数据存储之 SharedPreference 共享参数 (转)

        在上一讲中,我们学习了如何将数据存储在SD卡中[数据存储之File文件存储 [即SD卡的写入与读取]],这是一种存储方式,这一讲我们来学习一下使用SharedPreferences存储数据. ...

  4. android 开发-数据存储之共享参数

    android提供5中数据存储方式 数据存储之共享参数 内部存储 扩展存储 数据库存储 网络存储  而共享存储提供一种可以让用户存储保存一些持久化键值对在文件中,以供其他应用对这些共享参数进行调用.共 ...

  5. PCTUSED和PCTFREE对数据操作的影响

    1概念理解 首先PCTUSED和PCTFREE都是针对数据块的存储属性,单位都是%.其中PCTFREE决定了数据块什么时候从free list中移除,系统就不可以再往该数据块中插入数据,对于数据块中已 ...

  6. 智能合约语言 Solidity 教程系列4 - 数据存储位置分析

    写在前面 Solidity 是以太坊智能合约编程语言,阅读本文前,你应该对以太坊.智能合约有所了解, 如果你还不了解,建议你先看以太坊是什么 这部分的内容官方英文文档讲的不是很透,因此我在参考Soli ...

  7. CSAPP-过程调用,数据存储,缓冲区溢出

    程序编译: 1.预处理阶段: 1.文件包含:将#include扩展成文件正文 2.条件编译:根据#if和#ifdef将程序的某部分排除或者包含 3.宏展开:将出现宏引用的地方展开成相应的宏 2.编译阶 ...

  8. H5本地存储详细使用教程(localStorage + JSON数据存储应用框架)

    一.Web Storage教程 1.概述: 对于Web Storage来说,实际上是Cookies存储的进化版.如果了解Cookie的人几乎一看Web Storage就会用,如果你从来没用过没了解过C ...

  9. Hashtable数据存储结构-遍历规则,Hash类型的复杂度为啥都是O(1)-源码分析

    Hashtable 是一个很常见的数据结构类型,前段时间阿里的面试官说只要搞懂了HashTable,hashMap,HashSet,treeMap,treeSet这几个数据结构,阿里的数据结构面试没问 ...

  10. ubuntu14.04 rabbitmq安装与使用 --修改RabbitMQ数据存储位置

    参考:https://blog.csdn.net/tianjiewang/article/details/58383062 说明: ubuntu14.04   rabiitmq 默认 安装路径 /va ...

随机推荐

  1. Laravel入坑指南(番外)——任务调度

    Laravel提供了非常强劲的命令行工具(如果还不了解,传送到第8往篇),我们如果想要定期执行某个命令行,可以利用crontab进行定时设置.如果有多个定期的任务,很简单,我们设定多条crontab规 ...

  2. letcode-Z字抖动

    题目 将一个给定字符串 s 根据给定的行数 numRows ,以从上往下.从左到右进行 Z 字形排列. 比如输入字符串为 "PAYPALISHIRING" 行数为 3 时,排列如下 ...

  3. 发送HTML模板邮件

    概述 为了增强邮件内容展示的样式,可以将普通的文本邮件转换为HTML内容格式. 在Java中,可以通过页面模板技术来实现.具体来说,可以使用Thymeleaf模板. 具体实现 首先,在项目中引入Thy ...

  4. 红胖子(红模仿)的博文大全:开发技术集合大版本更新v4.0.0

    <红胖子(红模仿)的博文大全:开发技术集合(包含Qt实用技术.树莓派.三维.OpenCV.OpenGL.ffmpeg.OSG.单片机.软硬结合等等)持续更新中...>大版本更新,更新后版本 ...

  5. 【Azure 事件中心】适用Mirror Maker生产数据发送到Azure Event Hub出现发送一段时间后Timeout Exception: Expiring 18 record(s) for xxxxxxx: 79823 ms has passed since last append

    问题描述 根据"将 Apache Kafka MirrorMaker 与事件中心配合使用"一文,成功配置了Mirror Maker来发送数据到Event Hub中.为什么只能成功运 ...

  6. Nebula Operator 云上实践

    本文首发于 Nebula Graph Community 公众号 嗨,大家好!Nebula Operator 开源也有一段时间了,之前也有一篇相关的博客介绍,但是实践相关的博客却还没有,现在: 它来了 ...

  7. ArrayList学习总结

    1.ArrayList简介[1] ArrayList实现了List接口.ArrayList的方法实现和vector相似,只是线程不安全的. ArrayList的 size.isEmpty.get.se ...

  8. 【小程序分包】小程序包大于2M,来这教你分包啊

    前言 缘由 该大的不大,小程序包超出2M,无法上传发布 前段时间项目迭代时,因版本大升级,导致uniapp打包后小程序后,包体积大于2M.虽然将图片等静态资源压缩,体积大的资源放置cdn,在不懈的努力 ...

  9. SpringCloudStream消息驱动

    1. 基本介绍 官方文档: https://spring.io/projects/spring-cloud-stream#learn 背景: 在一般的大型项目中,或者分布式微服务结构的系统里,一般都会 ...

  10. Java 包装类的使用 + 小练习

    1 package com.bytezreo.ut; 2 3 import org.junit.Test; 4 5 /** 6 * 7 * @Description 包装类的使用 8 * @autho ...