参考之前提问 obclient -e里面 有 gv$视图表 要用’‘单引号括起来,__all虚拟表是 “” 双引号括起来,如果是关联查询,obclent 就报错了
obclient -h172.16.1.aa -P2883 -uroot@sys#aaa -p’aaaaa’ -A oceanbase -e’
select * from __all_virtual_processlist a, gv$sql_audit b where a.info is not null and a.sql_id=b.sql_id and tenant=‘sys’;’
类似这种关联一起的 obclient 就报错了
报啥错
报错 Usage: obclient [OPTIONS] [database]
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
The following groups are read: mysql mariadb-client client client-server client-mariadb
The following options may be given as the first argument:
-D oceanbase试试
[root@aa ~]# obclient -h172.16.1.11 -P2883 -uroot@sys#aa -p’aa’ -c -D oceanbase -e’select * from __all_virtual_processlist a, gv$sql_audit b where a.info is not null and a.sql_id=b.sql_id;’
ERROR 1049 (42000): Unknown database ‘,id),a.tenant from __all_virtual_processlist a, gv$sql_audit b where a.info is not null and a.sql_id=b.sql_id;’
[root@aa1 ~]# obclient -h172.16.1.11 -P2883 -uroot@sys#aa -p’aa’ -c -D oceanbase
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
谢谢提醒 谜底揭晓 obclient -h172.16.1.aa -P2883 -uroot@sys#aa -p’aa’ -c -A oceanbase -e’select b.TENANT_ID,a.svr_ip,a.svr_port,b.PLAN_ID,a.sql_id,a.state,a.user ,left(a.info,50),concat(“kill”, a.id),a.tenant from __all_virtual_processlist a, gv$sql_audit b where a.info is not null and a.sql_id=b.sql_id;’
语句报错的原因不是前面obclient抬头问题,因为其他语句都执行没有问题 ,错在里杀会话的拼接语句 ,concat(“kill”, a.id), 之前是单引号,我换了双引号就可以正常执行了,谢谢各位。 报错有点乱,以及之前id 没有加上表缩写抬头,现在已经正常了。