我刚刚创建了一个新用户,我希望它可以访问我们有限数量的公共表。用户已创建,我现在将 privs 授予一个公共表。然后,我以该用户身份登录数据库,并尝试在用户应该能够访问的表上运行 SELECT,但我必须错过一个步骤或做错了什么,因为当我运行查询时,我得到:
关系 [表] 不存在
以下是我按顺序执行的步骤。
CREATE USER pqb2b WITH PASSWORD 'foo'
select * from pg_user;
usename | usesysid | usecreatedb | usesuper | usecatupd | passwd | valuntil | useconfig
----------+----------+-------------+----------+-----------+----------+---- |
postgres | 10 | t | t | t | ******** | |
pgb2b | 17267767 | t | f | f | ******** | infinity |
(1 行)
GRANT ALL on b_users to pgb2b;
SELECT
schemaname||'.'||tablename
FROM
pg_tables
WHERE
has_table_privilege (
'pgb2b',
schemaname||'.'||tablename,
'select'
)
AND
schemaname NOT IN (
'pg_catalog',
'information_schema'
);
public.b_users
(1 row)
~ postgres$ psql -U pgb2b mydb
psql (9.0.3)
Type "help" for help.
mydb=> select * from b_users;
ERROR: relation "b_users" does not exist
LINE 1: select * from b_users;
mydb=> \d+ b_users
Did not find any relation named "b_users".