has_schema_privilege()

一个系统函数,用于确定用户是否对某个 schema 拥有特权

has_schema_privilege() 是一个系统函数,用于确定用户是否对指定的 schema 拥有指定的 特权

has_schema_privilege()PostgreSQL 7.3 中引入。

用法

has_schema_privilege() 有两种形式:

  • has_schema_privilege(schema TEXT 或 OID, privilege TEXT)
  • has_schema_privilege(user TEXT 或 OID, schema TEXT 或 OID, privilege TEXT)

可以查询以下权限

  • CREATE
  • 用法

变更历史

示例

确定当前用户是否对指定的 schema 拥有 USAGE 特权

postgres=# SELECT has_schema_privilege('public', 'USAGE');
 has_schema_privilege 
----------------------
 t
(1 row)

确定指定用户是否对指定的 schema 拥有 USAGE 特权

postgres=# SELECT has_schema_privilege('someuser', 'foo', 'USAGE');
 has_schema_privilege
----------------------
 f
(1 row)

尝试确定此对象类型不受识别的权限

postgres=# SELECT has_schema_privilege('public', 'DELETE');
ERROR:  unrecognized privilege type: "DELETE"

尝试确定不存在函数的特权

postgres=# SELECT has_schema_privilege('foo', 'USAGE');
ERROR:  schema "foo" does not exist

分类

Schema (命名空间), 系统函数, 用户和角色

反馈

提交对 "has_schema_privilege()" 的任何评论、建议或更正,请 在此处