GBase 8a
运维管理
文章

GBase 8a 系统表使用

发表于2024-12-30 19:46:3632次浏览0个评论

1、information_schema

1、库内表为系统视图(MEMORY 引擎表,只读),在查询时通过检索扫描相关文件获取集群的元数据信息,如库或表的名称、列的数据类型、访问权限、数据加载结果及状态信息、资源信息等;

查询示例:
1、查询VC虚拟集群
select * from information_schema.vc;
show vcs;

2、查询数据库
select schema_name as `Database` from information_schema.schemata;
show databases;
show schemas ;

3、查询某个库所有的表和视图
select table_name,table_type from information_schema.tables where table_schema='test' ;
show tables from test like 's%';

4、查询某个表中的列
select column_name,data_type,is_nullable,column_default from information_schema.columns where table_schema='test' and table_name='student';
show columns from test.student;
desc test.student;

5、查询存储过程和自定义函数
select routine_schema,routine_name,routine_type from information_schema.routines;

6、查询索引信息
select TABLE_NAME,INDEX_NAME,SEQ_IN_INDEX,COLUMN_NAME  from information_schema.statistics where table_schema= 'student' ;
show index from test.student;

7、查看创建存储过程的语句
show create procedure p_demo;

8、判断分布表数据分布没有倾斜
- cluster_table_segments:记录每个分片的数据占用磁盘空间信息
select * from information_schema.cluster_table_segments where table_schema = 'test' and table_name = 'student' ;
 

 

 

2、performation_schema

1、与information_schema 库相似,库内表为系统视图,区别在于performance_schema用于监控数据库本地运行时的信息,包括运行状态信息、磁盘、内存使用情况等;

查询示例:
1、查看当前节点gcluster层磁盘空间的使用信息
select * from performance_schema.disk_usage_info;

2、查看集群某节点的gcluster层和gnode层磁盘空间使用信息
select * from performance_schema.cluster_disk_usage_info where host = 'HOST-e6925ce' ;

3、如何查询表总条数
- table_rows:为表所有分片的条数和,当表分片有一个副本时,是表条数的2倍;当表分片有两个副本时,是表条数的3倍
select count(*) from test.student ;
select table_schema,table_name,round(table_rows)rows,round(storage_size/2/1024) storage_size_kb from performance_schema.tables where table_schema='test' and table_name='student';

评论

登录后才可以发表评论