Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add doc of keep_user_target_list_in_result #1067

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# keep_user_target_list_in_result 保持查询结果集列名与用户指定大小写一致

在 MatrixOne 查询中,保持结果集列名与用户指定的名称大小一致,除了可以通过使用别名(alias)来实现,还可以通过设置参数来实现。

`keep_user_target_list_in_result` 是 MatrixOne 设置查询结果集列名与用户指定的名称大小写是否一致的一个全局参数。

## 查看 keep_user_target_list_in_result

在 MatrixOne 中使用以下命令查看 `keep_user_target_list_in_result`:

```sql
show variables like "keep_user_target_list_in_result";--默认为 0
```

## 设置 keep_user_target_list_in_result

在 MatrixOne 中使用以下命令设置 `keep_user_target_list_in_result`:

```sql
set global keep_user_target_list_in_result = 0;--默认为 0,重新连接数据库生效
```

## 配置

在命令行执行以下语句:

```sql
set global keep_user_target_list_in_result = 1;// 默认为 0,重新连接数据库生效
```

## 示例

```sql
create table t1(aa int, bb int, cc int, AbC varchar(25), A_BC_d double);
insert into t1 values (1,2,3,'A',10.9);

mysql> select * from t1;
+------+------+------+------+--------+
| aa | bb | cc | abc | a_bc_d |
+------+------+------+------+--------+
| 1 | 2 | 3 | A | 10.9 |
+------+------+------+------+--------+
1 row in set (0.00 sec)

mysql> select @@keep_user_target_list_in_result;--查询参数值,默认关闭
+-----------------------------------+
| @@keep_user_target_list_in_result |
+-----------------------------------+
| 0 |
+-----------------------------------+
1 row in set (0.01 sec)

mysql> select aA, bB, CC, abc, a_Bc_D from t1;--在设置关闭情况下,查询结果集列名与用户指定的名称大小写不一致
+------+------+------+------+--------+
| aa | bb | cc | abc | a_bc_d |
+------+------+------+------+--------+
| 1 | 2 | 3 | A | 10.9 |
+------+------+------+------+--------+
1 row in set (0.00 sec)

mysql> set global keep_user_target_list_in_result =1;--开启查询结果集列名与用户指定的名称大小一致设置
Query OK, 0 rows affected (0.01 sec)

mysql> exit;--退出数据库重新连接后参数生效

mysql> select @@keep_user_target_list_in_result;--查询参数值,开启成功
+-----------------------------------+
| @@keep_user_target_list_in_result |
+-----------------------------------+
| 1 |
+-----------------------------------+
1 row in set (0.00 sec)

mysql> select aA, bB, CC, abc, a_Bc_D from t1;--在设置开启情况下,查询结果集列名与用户指定的名称大小写一致
+------+------+------+------+--------+
| aA | bB | CC | abc | a_Bc_D |
+------+------+------+------+--------+
| 1 | 2 | 3 | A | 10.9 |
+------+------+------+------+--------+
1 row in set (0.00 sec)

```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ nav:
- 时区支持: MatrixOne/Reference/Variable/system-variables/timezone.md
- 大小写敏感支持: MatrixOne/Reference/Variable/system-variables/lower_case_tables_name.md
- 外键检查支持: MatrixOne/Reference/Variable/system-variables/foreign_key_checks.md
- 查询结果集列名与用户指定大小写一致支持: MatrixOne/Reference/Variable/system-variables/keep_user_target_list_in_result.md
- 自定义变量: MatrixOne/Reference/Variable/custom-variable.md
- SQL 结构与语法:
- 关键字: MatrixOne/Reference/Language-Structure/keywords.md
Expand Down
Loading