Skip to content

Commit cde87b5

Browse files
committed
add usage document
1 parent 7e8ce9f commit cde87b5

File tree

6 files changed

+107
-2
lines changed

6 files changed

+107
-2
lines changed

CN/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
*** xref:master/7.18.adoc[18、Force View]
6262
*** xref:master/7.19.adoc[19、嵌套子函数]
6363
*** xref:master/7.20.adoc[20、sys_guid 函数]
64+
*** xref:master/7.21.adoc[21、空字符串转null]
6465
** IvorySQL贡献指南
6566
*** xref:master/8.1.adoc[社区贡献指南]
6667
*** xref:master/8.2.adoc[asciidoc语法快速参考]

CN/modules/ROOT/pages/master/7.20.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ IvorySQL的sys_guid() 是一个强大的随机数产生函数,它产生并返
1212
== 使用示例
1313

1414
```
15-
highgo=# select sys_guid() from dual;
15+
ivorysql=# select sys_guid() from dual;
1616
sys_guid
1717
------------------------------------
1818
\x3ed9426c8a093442a38bea09a74f44a1
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
:sectnums:
2+
:sectnumlevels: 5
3+
4+
:imagesdir: ./_images
5+
6+
= 兼容Oracle 空字符串转NULL
7+
8+
== 目的
9+
10+
- 在 IvorySQL 的 Oracle 兼容模式下,支持将空字符串转换成NULL进行存储,提供与Oracle数据库一致的行为。
11+
12+
== 功能说明
13+
14+
- Oracle兼容模式下支持将空字符串转换成NULL进行存储。
15+
- 通过参数 `ivorysql.enable_emptystring_to_null` 控制该特性,默认值为 `on`。
16+
- 当该参数开启时,插入空字符串会自动转换为NULL值存储。
17+
- 可以通过 `IS NULL` 条件查询到转换后的NULL值。
18+
19+
== 测试用例
20+
21+
[source,sql]
22+
----
23+
-- 创建测试表
24+
ivorysql=# create table abc (id int);
25+
CREATE TABLE
26+
27+
-- 查看空字符串转NULL参数状态
28+
ivorysql=# show ivorysql.enable_emptystring_to_null;
29+
ivorysql.enable_emptystring_to_NULL
30+
-------------------------------------
31+
on
32+
(1 row)
33+
34+
-- 插入空字符串
35+
ivorysql=# insert into abc values('');
36+
INSERT 0 1
37+
38+
-- 查询表数据,显示为NULL
39+
ivorysql=# select * from abc;
40+
id
41+
----
42+
43+
(1 row)
44+
45+
-- 使用IS NULL条件查询
46+
ivorysql=# select * from abc where id is null;
47+
id
48+
----
49+
50+
(1 row)
51+
----

EN/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
** xref:master/7.18.adoc[18、Force View]
6161
** xref:master/7.19.adoc[19、Nested Subfunctions]
6262
** xref:master/7.20.adoc[20、sys_guid Function]
63+
** xref:master/7.21.adoc[21、Empty String to NULL]
6364
* xref:master/8.adoc[Community contribution]
6465
* xref:master/9.adoc[Tool Reference]
6566
* xref:master/10.adoc[FAQ]

EN/modules/ROOT/pages/master/7.20.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ IvorySQL's sys_guid() is a powerful random number generation function that gener
1212
== Usage example
1313

1414
```
15-
highgo=# select sys_guid() from dual;
15+
ivorysql=# select sys_guid() from dual;
1616
sys_guid
1717
------------------------------------
1818
\x3ed9426c8a093442a38bea09a74f44a1
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
:sectnums:
2+
:sectnumlevels: 5
3+
4+
:imagesdir: ./_images
5+
6+
= Oracle Compatible Empty String to NULL
7+
8+
== Purpose
9+
10+
- In IvorySQL's Oracle compatibility mode, support converting empty strings to NULL for storage, providing behavior consistent with Oracle Database.
11+
12+
== Feature Description
13+
14+
- Oracle compatibility mode supports converting empty strings to NULL for storage.
15+
- The feature is controlled by parameter `ivorysql.enable_emptystring_to_null`, with default value `on`.
16+
- When this parameter is enabled, inserting an empty string will automatically convert it to NULL value for storage.
17+
- NULL values after conversion can be queried using the `IS NULL` condition.
18+
19+
== Test Cases
20+
21+
[source,sql]
22+
----
23+
-- Create test table
24+
ivorysql=# create table abc (id int);
25+
CREATE TABLE
26+
27+
-- Check empty string to NULL parameter status
28+
ivorysql=# show ivorysql.enable_emptystring_to_null;
29+
ivorysql.enable_emptystring_to_NULL
30+
-------------------------------------
31+
on
32+
(1 row)
33+
34+
-- Insert empty string
35+
ivorysql=# insert into abc values('');
36+
INSERT 0 1
37+
38+
-- Query table data, displays as NULL
39+
ivorysql=# select * from abc;
40+
id
41+
----
42+
43+
(1 row)
44+
45+
-- Query using IS NULL condition
46+
ivorysql=# select * from abc where id is null;
47+
id
48+
----
49+
50+
(1 row)
51+
----
52+

0 commit comments

Comments
 (0)