南大通用GBase 8a集群统一字段列名大小写的参数和例子

GBase 8a提供了2类场景来支持大小写:第一是查看表结构,支持默认,全改小写,全改大写的输出;第二是查询带表头的导出with head, 支持是否大小写敏感,默认输出小写。

查看表结构

参数

通过参数gbase_show_ident_case_sensitive控制
0 = 默认, 创建时指定的一致
1 = 小写, 所有列名输出小写
2 = 大写, 所有列名输出大写

影响范围

show create table/view
desc table_name
show column
show index
columns元数据表
gcdump导出表结构时

涉及版本:8.6.2Build43R20
测试版本:V9.5.2.23

样例

gbase> set global gbase_show_ident_case_sensitive=2;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)

gbase>
gbase>
gbase> select * from colors;
+----------+-------------+
| color_id | color_value |
+----------+-------------+
| c001     | Red         |
| c002     | Yellow      |
| c003     | Green       |
| c004     | Black       |
| c005     | White       |
+----------+-------------+
5 rows in set (Elapsed: 00:00:00.01)

gbase>
gbase>
gbase>
gbase> desc colors;
+-------------+--------------+------+-----+---------+-------+
| Field       | Type         | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| COLOR_ID    | varchar(100) | YES  |     | NULL    |       |
| COLOR_VALUE | varchar(100) | YES  |     | NULL    |       |
+-------------+--------------+------+-----+---------+-------+
2 rows in set (Elapsed: 00:00:00.01)

gbase> show create table colors;
+--------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table  | Create Table                                                                                                                                                                |
+--------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| colors | CREATE TABLE "colors" (
  "COLOR_ID" varchar(100) DEFAULT NULL,
  "COLOR_VALUE" varchar(100) DEFAULT NULL
) ENGINE=EXPRESS DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' |
+--------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.01)

查询导出的标题

参数

导出文件表头大小写敏感功能开关。

1=敏感
0=不敏感,改成小写

默认关闭。

_gcluster_support_outfile_with_table_head_case_sensitive

样例

如下通过参数,将MB和Mb做了导出文件的表头区分。 select into outfile with head

gbase> show variables like '%sensitive%';
+----------------------------------------------------------+-------+
| Variable_name                                            | Value |
+----------------------------------------------------------+-------+
| _gcluster_support_outfile_with_table_head_case_sensitive | 0     |
| gbase_show_ident_case_sensitive                          | 0     |
| gcluster_dblink_orcl_case_sensitive                      | 0     |
+----------------------------------------------------------+-------+
3 rows in set (Elapsed: 00:00:00.00)

gbase> set _gcluster_support_outfile_with_table_head_case_sensitive=1;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)

gbase>
gbase> select 123 as MB,456 as Mb from dual into outfile '/home/gbase/t1.txt' with head writemode by overwrites;
Query OK, 1 row affected (Elapsed: 00:00:00.00)

gbase> system cat /home/gbase/t1.txt/t1.txt
MB      Mb
123     456
gbase>