暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

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

原创 手机用户6666 2022-06-29
534

在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)
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论