バージョンごとのドキュメント一覧

REVOKE

REVOKE <refpurpose>remove access privileges</refpurpose> — アクセス権限を取り消す

概要

REVOKE [ GRANT OPTION FOR ]
    { { SELECT | INSERT | UPDATE | DELETE | TRUNCATE | REFERENCES | TRIGGER }
    [, ...] | ALL [ PRIVILEGES ] }
    ON { [ TABLE ] table_name [, ...]
         | ALL TABLES IN SCHEMA schema_name [, ...] }
    FROM role_specification [, ...]
    [ GRANTED BY role_specification ]
    [ CASCADE | RESTRICT ]

REVOKE [ GRANT OPTION FOR ]
    { { SELECT | INSERT | UPDATE | REFERENCES } ( column_name [, ...] )
    [, ...] | ALL [ PRIVILEGES ] ( column_name [, ...] ) }
    ON [ TABLE ] table_name [, ...]
    FROM role_specification [, ...]
    [ GRANTED BY role_specification ]
    [ CASCADE | RESTRICT ]

REVOKE [ GRANT OPTION FOR ]
    { { USAGE | SELECT | UPDATE }
    [, ...] | ALL [ PRIVILEGES ] }
    ON { SEQUENCE sequence_name [, ...]
         | ALL SEQUENCES IN SCHEMA schema_name [, ...] }
    FROM role_specification [, ...]
    [ GRANTED BY role_specification ]
    [ CASCADE | RESTRICT ]

REVOKE [ GRANT OPTION FOR ]
    { { CREATE | CONNECT | TEMPORARY | TEMP } [, ...] | ALL [ PRIVILEGES ] }
    ON DATABASE database_name [, ...]
    FROM role_specification [, ...]
    [ GRANTED BY role_specification ]
    [ CASCADE | RESTRICT ]

REVOKE [ GRANT OPTION FOR ]
    { USAGE | ALL [ PRIVILEGES ] }
    ON DOMAIN domain_name [, ...]
    FROM role_specification [, ...]
    [ GRANTED BY role_specification ]
    [ CASCADE | RESTRICT ]

REVOKE [ GRANT OPTION FOR ]
    { USAGE | ALL [ PRIVILEGES ] }
    ON FOREIGN DATA WRAPPER fdw_name [, ...]
    FROM role_specification [, ...]
    [ GRANTED BY role_specification ]
    [ CASCADE | RESTRICT ]

REVOKE [ GRANT OPTION FOR ]
    { USAGE | ALL [ PRIVILEGES ] }
    ON FOREIGN SERVER server_name [, ...]
    FROM role_specification [, ...]
    [ GRANTED BY role_specification ]
    [ CASCADE | RESTRICT ]

REVOKE [ GRANT OPTION FOR ]
    { EXECUTE | ALL [ PRIVILEGES ] }
    ON { { FUNCTION | PROCEDURE | ROUTINE } function_name [ ( [ [ argmode ] [ arg_name ] arg_type [, ...] ] ) ] [, ...]
         | ALL { FUNCTIONS | PROCEDURES | ROUTINES } IN SCHEMA schema_name [, ...] }
    FROM role_specification [, ...]
    [ GRANTED BY role_specification ]
    [ CASCADE | RESTRICT ]

REVOKE [ GRANT OPTION FOR ]
    { USAGE | ALL [ PRIVILEGES ] }
    ON LANGUAGE lang_name [, ...]
    FROM role_specification [, ...]
    [ GRANTED BY role_specification ]
    [ CASCADE | RESTRICT ]

REVOKE [ GRANT OPTION FOR ]
    { { SELECT | UPDATE } [, ...] | ALL [ PRIVILEGES ] }
    ON LARGE OBJECT loid [, ...]
    FROM role_specification [, ...]
    [ GRANTED BY role_specification ]
    [ CASCADE | RESTRICT ]

REVOKE [ GRANT OPTION FOR ]
    { { SET | ALTER SYSTEM } [, ...] | ALL [ PRIVILEGES ] }
    ON PARAMETER configuration_parameter [, ...]
    FROM role_specification [, ...]
    [ GRANTED BY role_specification ]
    [ CASCADE | RESTRICT ]

REVOKE [ GRANT OPTION FOR ]
    { { CREATE | USAGE } [, ...] | ALL [ PRIVILEGES ] }
    ON SCHEMA schema_name [, ...]
    FROM role_specification [, ...]
    [ GRANTED BY role_specification ]
    [ CASCADE | RESTRICT ]

REVOKE [ GRANT OPTION FOR ]
    { CREATE | ALL [ PRIVILEGES ] }
    ON TABLESPACE tablespace_name [, ...]
    FROM role_specification [, ...]
    [ GRANTED BY role_specification ]
    [ CASCADE | RESTRICT ]

REVOKE [ GRANT OPTION FOR ]
    { USAGE | ALL [ PRIVILEGES ] }
    ON TYPE type_name [, ...]
    FROM role_specification [, ...]
    [ GRANTED BY role_specification ]
    [ CASCADE | RESTRICT ]

REVOKE [ { ADMIN | INHERIT | SET } OPTION FOR ]
    role_name [, ...] FROM role_specification [, ...]
    [ GRANTED BY role_specification ]
    [ CASCADE | RESTRICT ]


<phrase>where <replaceable class="parameter">role_specification</replaceable> can be:</phrase>

ここでrole_specificationは以下の通りです。

    [ GROUP ] role_name
  | PUBLIC
  | CURRENT_ROLE
  | CURRENT_USER
  | SESSION_USER

説明

<title>Description</title>

The <command>REVOKE</command> command revokes previously granted privileges from one or more roles. The key word <literal>PUBLIC</literal> refers to the implicitly defined group of all roles. REVOKEコマンドは、1つ以上のロールに対して、以前に与えた権限を取り消します。 PUBLICキーワードは暗黙的に定義された全ロールからなるグループです。

See the description of the <link linkend="sql-grant"><command>GRANT</command></link> command for the meaning of the privilege types. 権限の種類の意味についてはGRANTコマンドの説明を参照してください。

Note that any particular role will have the sum of privileges granted directly to it, privileges granted to any role it is presently a member of, and privileges granted to <literal>PUBLIC</literal>. Thus, for example, revoking <literal>SELECT</literal> privilege from <literal>PUBLIC</literal> does not necessarily mean that all roles have lost <literal>SELECT</literal> privilege on the object: those who have it granted directly or via another role will still have it. Similarly, revoking <literal>SELECT</literal> from a user might not prevent that user from using <literal>SELECT</literal> if <literal>PUBLIC</literal> or another membership role still has <literal>SELECT</literal> rights. 全てのロールは、そのロールに直接許可された権限、現在属しているロールに許可された権限、PUBLICに許可された権限という3つの権限を合わせた権限を持っていることに注意してください。 したがって、例えば、PUBLICからSELECT権限を取り消すことは、必ずしも全てのロールがそのオブジェクトに対するSELECT権限を失うことを意味しません。 権限が直接許可されているロール、あるいは、別ロール経由で許可されているロールは、SELECT権限を持ち続けます。 同様にユーザからSELECTを取り消しても、PUBLICまたはメンバとして属する他のロールがSELECT権限を持つ場合、SELECTの使用を拒否できません。

If <literal>GRANT OPTION FOR</literal> is specified, only the grant option for the privilege is revoked, not the privilege itself. Otherwise, both the privilege and the grant option are revoked. GRANT OPTION FORが指定された場合、権限自体ではなく、その権限のグラントオプションのみが取り消されます。 指定されていなければ、権限とグラントオプションの両方が取り消されます。

If a user holds a privilege with grant option and has granted it to other users then the privileges held by those other users are called dependent privileges. If the privilege or the grant option held by the first user is being revoked and dependent privileges exist, those dependent privileges are also revoked if <literal>CASCADE</literal> is specified; if it is not, the revoke action will fail. This recursive revocation only affects privileges that were granted through a chain of users that is traceable to the user that is the subject of this <literal>REVOKE</literal> command. Thus, the affected users might effectively keep the privilege if it was also granted through other users. グラントオプション付きの権限を保持しているユーザが、その権限を他ユーザに与えていた場合、与えられたユーザが保持する権限は依存権限と呼ばれます。 権限を与えたユーザ自身の権限やグラントオプションが取り消され、その権限に依存権限が存在する場合、CASCADEが指定されていると依存権限も取り消されます。指定されていなければ、権限の取り消しが失敗します。 この再帰的な権限の取り消しは、ユーザ権限の連鎖を通じて与えられた権限の中でも、REVOKEを実行されたユーザから追跡可能な範囲にのみ影響します。 したがって、依存権限を持つユーザが他のユーザからも同じ権限を与えられている場合は、REVOKEが実行された後もその権限を保持している可能性があります。

When revoking privileges on a table, the corresponding column privileges (if any) are automatically revoked on each column of the table, as well. On the other hand, if a role has been granted privileges on a table, then revoking the same privileges from individual columns will have no effect. テーブルの権限を取り消す場合、対応する列の権限(もしあれば)も自動的に、そのテーブルの各列から取り消されます。 一方、ロールがテーブルに対する権限を持つ場合、個々の列から同じ権限を取り消しても影響ありません。

When revoking membership in a role, <literal>GRANT OPTION</literal> is instead called <literal>ADMIN OPTION</literal>, but the behavior is similar. Note that, in releases prior to <productname>PostgreSQL</productname> 16, dependent privileges were not tracked for grants of role membership, and thus <literal>CASCADE</literal> had no effect for role membership. This is no longer the case. Note also that this form of the command does not allow the noise word <literal>GROUP</literal> in <replaceable class="parameter">role_specification</replaceable>. ロールのメンバ資格を取り消す場合、同様に振舞いますが、GRANT OPTIONADMIN OPTIONと呼ばれます。 PostgreSQL 16より前のリリースでは、ロールメンバ資格の付与に対して依存権限が追跡されなかったため、CASCADEはロールメンバ資格に影響を与えなかったことに注意してください。 これはもはや当てはまりません。 このコマンド構文では、role_specificationで無意味なGROUPという単語を受け付けないことにも注意してください。

Just as <literal>ADMIN OPTION</literal> can be removed from an existing role grant, it is also possible to revoke <literal>INHERIT OPTION</literal> or <literal>SET OPTION</literal>. This is equivalent to setting the value of the corresponding option to <literal>FALSE</literal>. ADMIN OPTIONが既存のロール付与から削除できるのと同様に、INHERIT OPTIONまたはSET OPTIONを取り消すこともできます。 これは、対応するオプションの値をFALSEに設定することと同じです。

注釈

<title>Notes</title>

A user can only revoke privileges that were granted directly by that user. If, for example, user A has granted a privilege with grant option to user B, and user B has in turn granted it to user C, then user A cannot revoke the privilege directly from C. Instead, user A could revoke the grant option from user B and use the <literal>CASCADE</literal> option so that the privilege is in turn revoked from user C. For another example, if both A and B have granted the same privilege to C, A can revoke their own grant but not B's grant, so C will still effectively have the privilege. 取り消すことができるのは、ユーザが直接付与した権限のみです。 例えば、もし、ユーザAがグラントオプションを付けてユーザBに権限を与え、その後、ユーザBがユーザCにその権限を与えたとすると、ユーザAはユーザCの権限を直接取り消すことはできません。 その代わり、ユーザAがユーザBのグラントオプションをCASCADEオプション付きで取り消すことで、ユーザCに与えられた権限を取り消すことができます。 別の状況を考えてみます。AとBの両方が同じ権限をCに与えた場合、AはAの与えた権限を取り消すことはできますが、Bの与えた権限を取り消すことはできません。 したがって、Cは実質的にその権限を持ち続けることになります。

When a non-owner of an object attempts to <command>REVOKE</command> privileges on the object, the command will fail outright if the user has no privileges whatsoever on the object. As long as some privilege is available, the command will proceed, but it will revoke only those privileges for which the user has grant options. The <command>REVOKE ALL PRIVILEGES</command> forms will issue a warning message if no grant options are held, while the other forms will issue a warning if grant options for any of the privileges specifically named in the command are not held. (In principle these statements apply to the object owner as well, but since the owner is always treated as holding all grant options, the cases can never occur.) オブジェクトの所有者以外がそのオブジェクト上の権限に対してREVOKEを実行した場合、ユーザがオブジェクトに対して何の権限も持っていなければ、即座にコマンドが失敗します。 何らかの権限があればコマンド処理が続行されますが、取り消すことができるのはそのユーザがグラントオプションを持つ権限のみです。 REVOKE ALL PRIVILEGES構文をまったく権限を持たない状態で実行すると、警告が出力されます。 他の構文の場合は、そのコマンドで指定した権限に対するグラントオプションを持たない状態で実行すると、警告が出力されます (原理上、上記の説明はオブジェクト所有者にも適用されますが、所有者は常に全てのグラントオプションを保持しているので、こうした問題が発生することはありません)。

If a superuser chooses to issue a <command>GRANT</command> or <command>REVOKE</command> command, the command is performed as though it were issued by the owner of the affected object. (Since roles do not have owners, in the case of a <command>GRANT</command> of role membership, the command is performed as though it were issued by the bootstrap superuser.) Since all privileges ultimately come from the object owner (possibly indirectly via chains of grant options), it is possible for a superuser to revoke all privileges, but this might require use of <literal>CASCADE</literal> as stated above. スーパーユーザがGRANTREVOKEコマンドを発行した場合、そのコマンドは、対象のオブジェクトの所有者によって発行されたかのように実行されます。 (ロールには所有者がいないため、ロールメンバ資格のGRANTの場合には、コマンドはブートストラップスーパーユーザによって発行されたかのように実行されます。) 根本的には全ての権限はオブジェクトの所有者から渡されるものなので(ただし、グラントオプションの連鎖により間接的に渡される場合もありますが)、スーパーユーザは、全ての権限を取り消すことができます。 ただし、この場合は上述のCASCADEを使用する必要があるかもしれません。

<command>REVOKE</command> can also be done by a role that is not the owner of the affected object, but is a member of the role that owns the object, or is a member of a role that holds privileges <literal>WITH GRANT OPTION</literal> on the object. In this case the command is performed as though it were issued by the containing role that actually owns the object or holds the privileges <literal>WITH GRANT OPTION</literal>. For example, if table <literal>t1</literal> is owned by role <literal>g1</literal>, of which role <literal>u1</literal> is a member, then <literal>u1</literal> can revoke privileges on <literal>t1</literal> that are recorded as being granted by <literal>g1</literal>. This would include grants made by <literal>u1</literal> as well as by other members of role <literal>g1</literal>. REVOKEは、対象のオブジェクトの所有者以外のロールによって実行することもできますが、 オブジェクトを所有するロールのメンバであるか、そのオブジェクトに対しWITH GRANT OPTION権限を持つロールのメンバでなければなりません。 この場合、 そのオブジェクトの実際の所有者ロールまたはWITH GRANT OPTION権限を持つロールによって発行されたかのように、このコマンドは実行されます。 例えば、t1テーブルがg1ロールによって所有され、u1g1ロールのメンバであるとします。 この場合、u1g1で付与されたものと記録されている権限を取り消すことができます。 これには、u1が付与した権限とg1ロールの他のメンバによって付与された権限が含まれます。

If the role executing <command>REVOKE</command> holds privileges indirectly via more than one role membership path, it is unspecified which containing role will be used to perform the command. In such cases it is best practice to use <command>SET ROLE</command> to become the specific role you want to do the <command>REVOKE</command> as. Failure to do so might lead to revoking privileges other than the ones you intended, or not revoking anything at all. REVOKEを実行したロールが、ロールの持つ複数メンバ資格の経路を通して間接的に必要な権限を持つ場合、このコマンドがどのロールで実行されたかについては指定されません。 こうした場合、SET ROLEを使用して、REVOKEを行わせたい特定のロールになることを推奨します。 こうしないと、意図しない権限を取り消すことになったり、取り消し自体が失敗することになったりします。

See <xref linkend="ddl-priv"/> for more information about specific privilege types, as well as how to inspect objects' privileges. 特定の権限のより詳細な情報やオブジェクトの権限を調べる方法については5.7を参照してください。

<title>Examples</title>

Revoke insert privilege for the public on table <literal>films</literal>: テーブルfilmsに対するpublicに与えた挿入権限を取り消します。

REVOKE INSERT ON films FROM PUBLIC;

Revoke all privileges from user <literal>manuel</literal> on view <literal>kinds</literal>: ビューkindsから、ユーザmanuelに与えた全ての権限を取り消します。

REVOKE ALL PRIVILEGES ON kinds FROM manuel;

Note that this actually means <quote>revoke all privileges that I granted</quote>. これは実際には自分が与えた全ての権限を取り消すことを意味します。

Revoke membership in role <literal>admins</literal> from user <literal>joe</literal>: ユーザjoeからロールadmins内のメンバ資格を取り消します。

REVOKE admins FROM joe;

互換性

<title>Compatibility</title>

The compatibility notes of the <link linkend="sql-grant"><command>GRANT</command></link> command apply analogously to <command>REVOKE</command>. The keyword <literal>RESTRICT</literal> or <literal>CASCADE</literal> is required according to the standard, but <productname>PostgreSQL</productname> assumes <literal>RESTRICT</literal> by default. GRANTコマンドの互換性についての注釈はREVOKEにも同様に当てはまります。 標準では、キーワードRESTRICTCASCADEのどちらかが必須です。 しかし、PostgreSQLではデフォルトでRESTRICTとみなされます。

関連項目

<title>See Also</title> GRANT, ALTER DEFAULT PRIVILEGES