GBase 8a查看和修改表的拥有者UID

在GBase 8a数据集群中,每张表都有一个拥有者或所有者(owner, UID),该UID主要用于资源控制,比如磁盘空间等。本文介绍如何查看,修改表的拥有者UID。

查看

可以通过show 语句获得,也可以通过元数据表获得表的所有者UID。

语法

show full create table {TABLE_NAME};

或者从元数据表里查询

select table_schema,table_name,scn,table_id,owner_uid from information_schema.tables where table_schema={DBNAME} and table_name={TABLE_NAME};

样例

如下样例中的UID(1)表示该表的拥有者是UID=1。

gbase> show full create table t1;
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                    |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE "t1" (
  "id" int(11) DEFAULT NULL
) ENGINE=EXPRESS TID(105) UID(1) DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' COLUMN_IDS(0) |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.01)

通过元数据表查看

gbase> select table_vc,table_schema,table_name,scn,table_id,owner_uid,vc_id from information_schema.tables where table_schema='testdb' and table_name='t1';
+----------+--------------+------------+------+----------+-----------+---------+
| table_vc | table_schema | table_name | scn  | table_id | owner_uid | vc_id   |
+----------+--------------+------------+------+----------+-----------+---------+
| vc01     | testdb       | t1         | 2049 |      105 |         2 | vc00001 |
| vc02     | testdb       | t1         | 2049 |      105 |         2 | vc00002 |
+----------+--------------+------------+------+----------+-----------+---------+
2 rows in set (Elapsed: 00:00:00.00)

通过UID查看用户

可以从元数据表user里查看到UID对应的user名字。如下可以看到UID=1对应的是root数据库用户。

gbase> select trim(user),uid from gbase.user;
+------------+-----+
| trim(user) | uid |
+------------+-----+
| root       |   1 |
| gbase      |   2 |
| uservc1    | 102 |
| testdb     | 289 |
+------------+-----+
4 rows in set (Elapsed: 00:00:00.00)

修改

语法

alter table TABLE_NAME set owner USER_NAME

样例

如下例子将表的所有者从root(UID=1)改成了gbase(UID=2)

gbase> alter table t1 set owner gbase;
Query OK, 0 rows affected (Elapsed: 00:00:00.13)

gbase> show full create table t1;
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                    |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE "t1" (
  "id" int(11) DEFAULT NULL
) ENGINE=EXPRESS TID(105) UID(2) DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' COLUMN_IDS(0) |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

参考

GBase 8a查看表的tableId

GBase8a 集群查看建表结构,存储过程的语句

GBase 8a的show命令列表和使用

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注