文档首页> 数据仓库服务 GaussDB(DWS)> 故障排除> 账号/权限/密码> 赋予用户schema的all权限后建表仍然报错ERROR: current user does not have privilege to role tom
更新时间:2024-01-25 GMT+08:00

赋予用户schema的all权限后建表仍然报错ERROR: current user does not have privilege to role tom

问题现象

有两个用户tom和jerry,jerry需要在tom的同名schema下创建表,于是tom把该schema的all权限赋予jerry,但是创建表时仍然报错:

1
2
3
4
5
6
7
8
9
dbtest=# GRANT all on schema tom to jerry;
GRANT
dbtest=# \c - jerry
Password for user jerry: 
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "dbtest" as user "jerry".
dbtest=> 
dbtest=> CREATE TABLE tom.t(a int);
ERROR:  current user does not have privilege to role tom

原因分析

根据报错内容,jerry需要角色tom的权限。

处理方法

把角色tom的权限赋予jerry后,建表执行成功。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
dbtest=# GRANT tom to jerry;
GRANT ROLE
dbtest=# \c - jerry
Password for user jerry: 
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "dbtest" as user "jerry".
dbtest=> 
dbtest=> CREATE TABLE tom.t(a int);
NOTICE:  The 'DISTRIBUTE BY' clause is not specified. Using 'a' as the distribution column by default.
HINT:  Please use 'DISTRIBUTE BY' clause to specify suitable data distribution column.
CREATE TABLE