集群表名、字段名是否支持中文?

从862集群开始表名字段名支持中文字符,需要打开参数gcluster_extend_ident
参数gcluster_extend_ident,用来控制是否可以创建中文表名字段、特殊字符的字段。
默认为0,表示不开启,为1表示开启。
在gcluster_extend_ident为0的情况下,创建带有中文标识的库表,提示失败。
修改配置文件加入gcluster_extend_ident = 1,在不重启的情况下set global gcluster_extend_ident = 1开启,创建带有中文标识的库表,提示成功。

在8.6.2.18-R2.82869上测试,打开gcluster_extend_ident参数。

gbase> set global gcluster_extend_ident=1;
Query OK, 0 rows affected (Elapsed: 00:00:00.01)
gbase> \q
Bye
suse103:~ # gccli guo
GBase client 8.6.2.18-R2.82869. Copyright (c) 2004-2017, GBase.  All Rights Reserved.
gbase> create table 表(列1 int,列2 varchar(10));
Query OK, 0 rows affected (Elapsed: 00:00:01.10)

gbase> insert into 表 values(1,'a啊');
Query OK, 1 row affected (Elapsed: 00:00:00.03)

gbase> select * from 表;
 +------+------+
 | 列1  | 列2  |
 +------+------+
 |    1 | a啊  |
 +------+------+
1 row in set (Elapsed: 00:00:00.02)

为什么nocopies表不起作用?

8611版本集群建议不要使用nocopies表,后续版本将兼容nocopies属性,增加参数缺省关闭。建表时即使指定nocopies属性也按照正常表创建,基于性能考虑还可以使用nocopies表。

集群层sql和下发到节点层的sql,如何对应?

下发到节点层的sql中的注释信息包含集群层sql的id信息。
例如:
在集群层执行select * from lineorder;,下发节点gc层show processlist信息如下,sql id是102。

[root@pst-red214 ~]# gccli
GBase client 8.6.1.1-16.28.81413. Copyright (c) 2004-2017, GBase.  All Rights Reserved.
gbase> show processlist;
+-----+-----------------+-----------------+------+---------+-------+-----------------------------+-------------------------+
| Id  | User            | Host            | db   | Command | Time  | State                       | Info                    |
+-----+-----------------+-----------------+------+---------+-------+-----------------------------+-------------------------+
|   1 | event_scheduler | localhost       | NULL | Daemon  | 15044 | Waiting for next activation | NULL                    |
|  52 | root            | 127.0.0.1:38654 | NULL | Sleep   |  3414 |                             | NULL                    |
| 101 | root            | 127.0.0.1:38820 | NULL | Query   |     0 | NULL                        | show processlist        |
| 102 | root            | 127.0.0.1:38822 | guo  | Query   |     3 | Sending task to gnodes      | select * from lineorder |
+-----+-----------------+-----------------+------+---------+-------+-----------------------------+-------------------------+
4 rows in set (Elapsed: 00:00:00.00)

gn层show processlist如下,下发的sql中SELECT /*192.168.105.214_102_1_2017-07-03_14:28:29*/ /*+ TID('6561') */,包含集群层sql的id 102。

[root@pst-red214 ~]# gncli
GBase client 8.6.1.1-16.28.81413. Copyright (c) 2004-2017, GBase.  All Rights Reserved.
gbase> show processlist;
+-----+-------+-----------------------+---------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id  | User  | Host                  | db      | Command | Time | State        | Info                                                                                                 |
+-----+-------+-----------------------+---------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| 539 | gbase | 192.168.105.212:10034 | gctmpdb | Sleep   | 9962 | NULL         | NULL                                                                                                 |
| 630 | root  | 127.0.0.1:61898       | NULL    | Query   |    0 | NULL         | show processlist                                                                                     |
| 631 | root  | 192.168.105.214:57013 | gctmpdb | Query   |    6 | Sending data | SELECT /*192.168.105.214_102_1_2017-07-03_14:28:29*/ /*+ TID('6561') */ `guo.lineorder`.`lo_orderkey |
+-----+-------+-----------------------+---------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
3 rows in set (Elapsed: 00:00:00.00)

GBase 8a集群视图有哪些使用限制?

使用限制:
(1)视图名不能和现有表名重复
(2)创建视图时SELECT语句必须引用表或视图,且引用的表或视图必须存在
(3)视图所引用的表不能是临时表
(4)创建视图时SELECT语句不能使用系统或用户变量
(5)创建视图时SELECT语句中不能包含子查询
(6)创建视图时不能使用预处理语句参数,存储过程中的参数或局部变量
(7)在存储过程中不能修改ALTER视图
(8)不能给视图添加索引
(9)不能对视图进行INSERT、UPDATE和DELETE操作

如何修改审计日志的表结构?

审计日志表表结构
11.5_r12.4_R1.1版本对审计日志表表结构增加了4列。
原表结构:
start_time 开始执行的时间
user_host 登陆的用户名和host
query_time sql 执行的时间
rows 返回结果集行数
db sql 执行的当前数据库名
sql_text sql 内容
conn_type 用户登陆方式(CAPI、ODBC、JDBC、ADO)

审计日志表新增列的内容如下:
Taskid 全局唯一的任务号
End_time SQL执行结束的时间
Sql_type 标识SQL类型,DDL,DML,DQL,OTHERS
Status 标识SQL执行成功还是失败,SUCCESS,FAILED

项目上手动修改表结构。

修改审计日志表结构的方法
1)由于审计日志表是系统表,需要手工修改每个节点gcluster和gnode的审计日志表的表结构
2)修改审计日志表结构时需要关闭审计日志功能,set global audit_log=off;
3)修改审计日志表结构之前需要执行:set sql_mode=’’;
4)修改表结构有两种方法

  • 方法一,直接在原表上增加列

    Alter self table audit_log add column taskid bigint not null first;
    Alter self table audit_log add column end_time timestamp not null after start_time;
    Alter self table audit_log add column sql_type mediumtext not null after sql_text;
    Alter self table audit_log add column status mediumtext not null after sql_type;

  • 方法二,创建新表,倒数据后,替换原表

    Taskid bigint not null,
    Start_time timestamp not null,
    End_time timestamp not null,
    User_host mediumtext not null,
    Query_time time not null,
    Rows integer not null,
    Db varchar(512) not null,
    Sql_text mediumtext not null,
    Sql_type mediumtext not null,
    Status mediumtext not null,
    Conn_type mediumtext not null
    ) engine =gssys character set utf8 comment=’Audit log’;
    Insert into audit_log_new(start_time, user_host, query_time, rows, db, sql_text, conn_type) select * from audit_log;
    Alter self table audit_log rename to audit_log_bak;
    Alter self table audit_log_new rename to audit_log;
    5)替换完成后需要重新开启审计日志功能: set global audit_log=on;