Schema信息
Hubble提供了information_schema的虚schema,其中包含了数据库的表、列、索引和视图的信息。
包含的数据信息
| 对象 | Infomation Schema 中的表 | 使用show语句 |
|---|
| columns | columns | SHOW COLUMNS |
| Constraints | check_constraints, key_column_usage, referential_constraints, table_constraints | SHOW CONSTRAINTS |
| Databases | schemata | SHOW DATABASE |
| Indexes | statistics | SHOW INDEX |
| Privileges | schema_privileges,table_privileges | SHOW GRANTS |
| Roles | role_table_grants | SHOW ROLES |
| Sequences | sequences | SHOW CREATE SEQUENCE |
| Tables | tables | SHOW TABLES |
| Views | tables,views | SHOW CREATE |
administrable_role_authorizations
当前用户是否具有管理员权限的信息,如使用普通用户,查此表则为空
| 列名 | 描述 |
|---|
| grantee | 当前用户 |
| role_name | 所属角色 |
| is_grantable | 是否可授权 |
applicable_roles
标识当前用户可以使用其授权的所有角色。这意味着,存在一个从当前用户到相关角色的角色授予链。当前用户本身也是一个适用的角色,但是没有列出。
| 列名 | 描述 |
|---|
| grantee | 当前用户 |
| role_name | 所属角色 |
| is_grantable | 是否可授权 |
check_constraints
包含检查约束应用在具体数据库列的的信息
| 列名 | 描述 |
|---|
| constraint_catalog | 包含约束的数据库的名称 |
| constraint_schema | 包含约束的schema的名称 |
| constraint_name | 约束名称 |
| check_clause | 检查约束的定义。 |
columns
包含关于每个表中列的信息
| 列名 | 描述 |
|---|
| table_catalog | 包含表的数据库的名称 |
| table_schema | 包含表的schema的名称 |
| table_schema | 表名称 |
| table_schema | 列名称 |
| table_schema | 表中列的序号位置(从1开始)。 |
| column_default | 列的默认值。 |
| is_nullable | 如果该列接受空值,则为YES; |
| data_type | 列的数据类型 |
| character_maximum_length | 如果data_type是sting类型,则值的最大字符长度;否则无效。 |
| character_octet_length | 如果data_type是字符串,则值的最大长度为8字节;否则无效。 |
| numeric_precision | 如果data_type是数值型的,则声明的或隐式的精度,否则无效。 |
| numeric_precision_radix | 如果data_type数值型的,则表示numeric_precision和numeric_scale列中的值的基数(2或10)。对于所有其他数据类型,column为NULL |
| numeric_scale | 如果data_type是精确的数字类型,则表示精度 |
| datetime_precision | 保留字段 |
| character_set_catalog | 保留字段 |
| character_set_schema | 保留字段 |
| character_set_name | 保留字段 |
| domain_catalog | 保留字段 |
| domain_schema | 保留字段 |
| domain_name | 保留字段 |
| generation_expression | 用于计算列类型的计算表达式 |
| is_hidden | 是否为隐藏列 |
| hubbledb_sql_type | 列的数据类型 |
column_privileges
对于列的授予信息
| 列名 | 描述 |
|---|
| grantor | 授予权限的角色的名称 |
| grantee | 被授予权限的角色的名称 |
| table_catalog | 包含包含列的表的数据库的名称 |
| table_schema | 包含包含列的表的架构的名称 |
| table_name | 表明 |
| column_name | 列名 |
| privilege_type | 授权类型 |
| is_grantable | 保留字段 |
constraint_column_usage
某个约束使用的数据库中的所有列。
| 列名 | 描述 |
|---|
| table_catalog | 包含约束使用的列的表的数据库的名称 |
| table_schema | 包含表的schema的名称,该表包含某些约束使用的列 |
| table_name | 包含某些约束使用的列的表的名称 |
| column_name | 约束使用的列的名称 |
| constraint_catalog | 包含约束的数据库的名称 |
| constraint_schema | 包含约束的schema名称 |
| constraint_name | 约束名称 |
enabled_roles
当前用户的角色。这包括直接作用和间接作用。
key_column_usage
使用主键、惟一键或外键/引用约束的列信息
| 列名 | 描述 |
|---|
| constraint_catalog | 包含约束的数据库的名称 |
| constraint_schema | 包含约束的schema的名称 |
| constraint_name | 约束名称 |
| table_catalog | 包含约束表的数据库的名称 |
| table_schema | 包含约束表的schema的名称 |
| table_name | 约束表的名称 |
| column_name | 约束列的名称 |
| ordinal_position | 约束中列的序号位置(从1开始) |
| position_in_unique_constraint | 对于外键约束,引用列在其唯一性约束内的序号位置(从1开始) |
referential_constraints
| 列名 | 描述 |
|---|
| constraint_catalog | 包含约束的数据库的名称 |
| constraint_schema | 包含约束的架构的名称 |
| constraint_name | 约束名称 |
| unique_constraint_catalog | 包含外键约束引用的唯一或主键约束的数据库的名称(始终是当前数据库)。 |
| unique_constraint_schema | 包含外键约束引用的唯一或主键约束的schema的名称 |
| unique_constraint_name | 唯一或主键约束的名称 |
| match_option | 外键约束的匹配选项:FULL、PARTIAL或NONE |
| update_rule | 外键约束的更新规则:CASCADE, SET NULL, SET DEFAULT, RESTRICT, or NO ACTION |
| delete_rule | 外键约束的删除规则:CASCADE, SET NULL, SET DEFAULT, RESTRICT, or NO ACTION |
| table_name | 包含约束的表的名称 |
| referenced_table_name | 包含外键约束引用的唯一或主键约束的表的名称 |
role_table_grants
授予者或被授予者是当前启用角色的表或视图上授予了哪些特权。这个表与table_privileges相同。
| 列名 | 描述 |
|---|
| grantor | 授予权限的角色的名称 |
| grantee | 被授予特权的角色的名称 |
| table_catalog | 包含表的数据库的名称 |
| table_schema | 包含表的schema的名称 |
| table_name | 表名 |
| privilege_type | 授权名称 |
| is_grantable | 保留字段 |
| with_hierarchy | 保留字段 |
schema_privileges
数据库级别上为每个用户授予信息。
| 列名 | 描述 |
|---|
| grantee | 授权的用户名 |
| table_catalog | 包含约束表的数据库的名称。 |
| table_schema | 包含约束表的schema名称。 |
| table_schema | 特权的名称 |
| table_schema | 保留字段 |
schemata
数据库的schema信息
| 列名 | 描述 |
|---|
| table_catalog | 数据库名称 |
| table_schema | schema名称 |
| default_character_set_name | 保留字段 |
| sql_path | 保留字段 |
sequences
序列标识数据库中定义的序列
| 列名 | 描述 |
|---|
| sequence_catalog | 包含序列的数据库的名称 |
| sequence_schema | 包含序列的架构的名称 |
| sequence_name | 序列名称 |
| data_type | 序列的数据类型 |
| numeric_precision | 序列的精度 |
| numeric_precision_radix | 表示列numeric_\precision和numeric_scale的值的基数(进制)。值为2或10 |
| numeric_scale | 序列的精度 |
| start_value | 序列的第一个值 |
| minimum_value | 序列的最小值 |
| maximum_value | 序列的最大值 |
| increment | 序列递增的值。负数产生一个降序数列。一个正数产生一个升序 |
| cycle_option | 目前,所有的序列都被设置为无循环,序列不会换行 |
statistics
表的索引信息
| 列名 | 描述 |
|---|
| table_catalog | 包含约束表的数据库的名称 |
| table_schema | 包含约束表的schema的名称 |
| table_name | 表名 |
| non_unique | 如果索引是使用UNIQUE创建的,则为NO;如果没有使用UNIQUE创建索引,则为YES。 |
| index_schema | 包含索引的数据库的名称 |
| index_name | 索引名称 |
| seq_in_index | 索引中列的序号位置(从1开始) |
| column_name | 被索引的列的名称 |
| collation | 保留字段 |
| cardinality | 保留字段 |
| direction | 升序,降序 |
| storing | 如果存储了列,则为YES;如果它是索引的或隐式的则为NO |
| implicit | 如果列是隐式的(即,未在索引中指定,也未存储)为YES;如果它被索引或存储为NO |
table_constraints
应用于表的约束信息
| 列名 | 描述 |
|---|
| constraint_catalog | 包含约束的数据库的名称 |
| constraint_schema | 包含约束的schema的名称 |
| constraint_name | 约束的名称 |
| table_catalog | 包含约束表的数据库的名称 |
| table_schema | 包含约束表的schema的名称 |
| table_name | 约束表的名称 |
| constraint_type | 约束类型:CHECK、foreign key、PRIMARY KEY或UNIQUE |
| is_deferrable | 如果约束可以被延迟,则为no |
| initially_deferred | 如果约束是可延迟的且最初被延迟,则为YES;否则为NO |
table_privileges
表级别的每个用户的权限信息
| 列名 | 描述 |
|---|
| grantor | 保留字段 |
| grantee | 授权用户的用户名 |
| table_catalog | 授权应用于的数据库的名称 |
| table_schema | 授权应用于的schema的名称 |
| table_name | 授权应用于的表的名称 |
| privilege_type | 授权类型 |
| is_grantable | 保留字段 |
| with_hierarchy | 保留字段 |
tables
表与视图在数据库中的信息
| 列名 | 描述 |
|---|
| table_catalog | 包含表的数据库的名称 |
| table_schema | 包含表的schema的名称 |
| table_name | 表名 |
| table_type | 表的类型:普通表的基表、视图的视图或系统创建的视图的系统视图 |
| version | 表的版本号;版本从1开始,并且每次在表上发出ALTER TABLE语句时递增 |
user_privileges
包含了全局权限,且此视图仅包含root用户的全局特权
| 列名 | 描述 |
|---|
| grantee | 授权的用户名 |
| table_catalog | 应用于的数据库权限的名称 |
| privilege_type | 权限类型 |
| is_grantable | 保留字段 |
views
数据库中的视图信息
| 列名 | 描述 |
|---|
| table_catalog | 包含视图的数据库的名称 |
| table_schema | 包含视图的schema的名称 |
| table_name | 视图的名称。 |
| view_definition | 用于创建视图的子句 |
| check_option | 保留字段 |
| is_updatable | 保留字段 |
| is_insertable_into | 保留字段 |
| is_trigger_updatable | 保留字段 |
| is_trigger_deletable | 保留字段 |
| is_trigger_insertable_into | 保留字段 |