]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/grant.sgml
Fix psql doc typo.
[postgresql] / doc / src / sgml / ref / grant.sgml
1 <!--
2 doc/src/sgml/ref/grant.sgml
3 PostgreSQL documentation
4 -->
5
6 <refentry id="SQL-GRANT">
7  <refmeta>
8   <refentrytitle>GRANT</refentrytitle>
9   <manvolnum>7</manvolnum>
10   <refmiscinfo>SQL - Language Statements</refmiscinfo>
11  </refmeta>
12
13  <refnamediv>
14   <refname>GRANT</refname>
15   <refpurpose>define access privileges</refpurpose>
16  </refnamediv>
17
18  <indexterm zone="sql-grant">
19   <primary>GRANT</primary>
20  </indexterm>
21
22  <refsynopsisdiv>
23 <synopsis>
24 GRANT { { SELECT | INSERT | UPDATE | DELETE | TRUNCATE | REFERENCES | TRIGGER }
25     [, ...] | ALL [ PRIVILEGES ] }
26     ON { [ TABLE ] <replaceable class="PARAMETER">table_name</replaceable> [, ...]
27          | ALL TABLES IN SCHEMA <replaceable class="PARAMETER">schema_name</replaceable> [, ...] }
28     TO { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
29
30 GRANT { { SELECT | INSERT | UPDATE | REFERENCES } ( <replaceable class="PARAMETER">column</replaceable> [, ...] )
31     [, ...] | ALL [ PRIVILEGES ] ( <replaceable class="PARAMETER">column</replaceable> [, ...] ) }
32     ON [ TABLE ] <replaceable class="PARAMETER">table_name</replaceable> [, ...]
33     TO { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
34
35 GRANT { { USAGE | SELECT | UPDATE }
36     [, ...] | ALL [ PRIVILEGES ] }
37     ON { SEQUENCE <replaceable class="PARAMETER">sequence_name</replaceable> [, ...]
38          | ALL SEQUENCES IN SCHEMA <replaceable class="PARAMETER">schema_name</replaceable> [, ...] }
39     TO { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
40
41 GRANT { { CREATE | CONNECT | TEMPORARY | TEMP } [, ...] | ALL [ PRIVILEGES ] }
42     ON DATABASE <replaceable>database_name</replaceable> [, ...]
43     TO { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
44
45 GRANT { USAGE | ALL [ PRIVILEGES ] }
46     ON DOMAIN <replaceable>domain_name</replaceable> [, ...]
47     TO { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
48
49 GRANT { USAGE | ALL [ PRIVILEGES ] }
50     ON FOREIGN DATA WRAPPER <replaceable>fdw_name</replaceable> [, ...]
51     TO { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
52
53 GRANT { USAGE | ALL [ PRIVILEGES ] }
54     ON FOREIGN SERVER <replaceable>server_name</replaceable> [, ...]
55     TO { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
56
57 GRANT { EXECUTE | ALL [ PRIVILEGES ] }
58     ON { FUNCTION <replaceable>function_name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">arg_name</replaceable> ] <replaceable class="parameter">arg_type</replaceable> [, ...] ] ) [, ...]
59          | ALL FUNCTIONS IN SCHEMA <replaceable class="PARAMETER">schema_name</replaceable> [, ...] }
60     TO { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
61
62 GRANT { USAGE | ALL [ PRIVILEGES ] }
63     ON LANGUAGE <replaceable>lang_name</replaceable> [, ...]
64     TO { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
65
66 GRANT { { SELECT | UPDATE } [, ...] | ALL [ PRIVILEGES ] }
67     ON LARGE OBJECT <replaceable class="PARAMETER">loid</replaceable> [, ...]
68     TO { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
69
70 GRANT { { CREATE | USAGE } [, ...] | ALL [ PRIVILEGES ] }
71     ON SCHEMA <replaceable>schema_name</replaceable> [, ...]
72     TO { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
73
74 GRANT { CREATE | ALL [ PRIVILEGES ] }
75     ON TABLESPACE <replaceable>tablespace_name</replaceable> [, ...]
76     TO { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
77
78 GRANT { USAGE | ALL [ PRIVILEGES ] }
79     ON TYPE <replaceable>type_name</replaceable> [, ...]
80     TO { [ GROUP ] <replaceable class="PARAMETER">role_name</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
81
82 GRANT <replaceable class="PARAMETER">role_name</replaceable> [, ...] TO <replaceable class="PARAMETER">role_name</replaceable> [, ...] [ WITH ADMIN OPTION ]
83 </synopsis>
84  </refsynopsisdiv>
85
86  <refsect1 id="sql-grant-description">
87   <title>Description</title>
88
89   <para>
90    The <command>GRANT</command> command has two basic variants: one
91    that grants privileges on a database object (table, column, view, foreign
92    table, sequence, database, foreign-data wrapper, foreign server, function,
93    procedural language, schema, or tablespace), and one that grants
94    membership in a role.  These variants are similar in many ways, but
95    they are different enough to be described separately.
96   </para>
97
98  <refsect2 id="sql-grant-description-objects">
99   <title>GRANT on Database Objects</title>
100
101   <para>
102    This variant of the <command>GRANT</command> command gives specific
103    privileges on a database object to
104    one or more roles.  These privileges are added
105    to those already granted, if any.
106   </para>
107
108   <para>
109    There is also an option to grant privileges on all objects of the same
110    type within one or more schemas.  This functionality is currently supported
111    only for tables, sequences, and functions (but note that <literal>ALL
112    TABLES</> is considered to include views and foreign tables).
113   </para>
114
115   <para>
116    The key word <literal>PUBLIC</literal> indicates that the
117    privileges are to be granted to all roles, including those that might
118    be created later.  <literal>PUBLIC</literal> can be thought of as an
119    implicitly defined group that always includes all roles.
120    Any particular role will have the sum
121    of privileges granted directly to it, privileges granted to any role it
122    is presently a member of, and privileges granted to
123    <literal>PUBLIC</literal>.
124   </para>
125
126   <para>
127    If <literal>WITH GRANT OPTION</literal> is specified, the recipient
128    of the privilege can in turn grant it to others.  Without a grant
129    option, the recipient cannot do that.  Grant options cannot be granted
130    to <literal>PUBLIC</literal>.
131   </para>
132
133   <para>
134    There is no need to grant privileges to the owner of an object
135    (usually the user that created it),
136    as the owner has all privileges by default.  (The owner could,
137    however, choose to revoke some of his own privileges for safety.)
138   </para>
139
140   <para>
141    The right to drop an object, or to alter its definition in any way, is
142    not treated as a grantable privilege; it is inherent in the owner,
143    and cannot be granted or revoked.  (However, a similar effect can be
144    obtained by granting or revoking membership in the role that owns
145    the object; see below.)  The owner implicitly has all grant
146    options for the object, too.
147   </para>
148
149   <para>
150    PostgreSQL grants default privileges on some types of objects to
151    <literal>PUBLIC</literal>.  No privileges are granted to
152    <literal>PUBLIC</literal> by default on tables,
153    columns, schemas or tablespaces. For other types, the default privileges
154    granted to <literal>PUBLIC</literal> are as follows:
155    <literal>CONNECT</literal> and <literal>CREATE TEMP TABLE</literal> for
156    databases; <literal>EXECUTE</literal> privilege for functions; and
157    <literal>USAGE</literal> privilege for languages.
158    The object owner can, of course, <command>REVOKE</command>
159    both default and  expressly granted privileges. (For maximum
160    security, issue the <command>REVOKE</> in the same transaction that
161    creates the object; then there is no window in which another user
162    can use the object.)
163    Also, these initial default privilege settings can be changed using the
164    <xref linkend="sql-alterdefaultprivileges">
165    command.
166   </para>
167
168   <para>
169    The possible privileges are:
170
171    <variablelist>
172     <varlistentry>
173      <term>SELECT</term>
174      <listitem>
175       <para>
176        Allows <xref linkend="sql-select"> from
177        any column, or the specific columns listed, of the specified table,
178        view, or sequence.
179        Also allows the use of
180        <xref linkend="sql-copy"> TO.
181        This privilege is also needed to reference existing column values in
182        <xref linkend="sql-update"> or
183        <xref linkend="sql-delete">.
184        For sequences, this privilege also allows the use of the
185        <function>currval</function> function.
186        For large objects, this privilege allows the object to be read.
187       </para>
188      </listitem>
189     </varlistentry>
190
191     <varlistentry>
192      <term>INSERT</term>
193      <listitem>
194       <para>
195        Allows <xref linkend="sql-insert"> of a new
196        row into the specified table.  If specific columns are listed,
197        only those columns may be assigned to in the <command>INSERT</>
198        command (other columns will therefore receive default values).
199        Also allows <xref linkend="sql-copy"> FROM.
200       </para>
201      </listitem>
202     </varlistentry>
203
204     <varlistentry>
205      <term>UPDATE</term>
206      <listitem>
207       <para>
208        Allows <xref linkend="sql-update"> of any
209        column, or the specific columns listed, of the specified table.
210        (In practice, any nontrivial <command>UPDATE</> command will require
211        <literal>SELECT</> privilege as well, since it must reference table
212        columns to determine which rows to update, and/or to compute new
213        values for columns.)
214        <literal>SELECT ... FOR UPDATE</literal>
215        and <literal>SELECT ... FOR SHARE</literal>
216        also require this privilege on at least one column, in addition to the
217        <literal>SELECT</literal> privilege.  For sequences, this
218        privilege allows the use of the <function>nextval</function> and
219        <function>setval</function> functions.
220        For large objects, this privilege allows writing or truncating the
221        object.
222       </para>
223      </listitem>
224     </varlistentry>
225
226     <varlistentry>
227      <term>DELETE</term>
228      <listitem>
229       <para>
230        Allows <xref linkend="sql-delete"> of a row
231        from the specified table.
232        (In practice, any nontrivial <command>DELETE</> command will require
233        <literal>SELECT</> privilege as well, since it must reference table
234        columns to determine which rows to delete.)
235       </para>
236      </listitem>
237     </varlistentry>
238
239     <varlistentry>
240      <term>TRUNCATE</term>
241      <listitem>
242       <para>
243        Allows <xref linkend="sql-truncate"> on
244        the specified table.
245       </para>
246      </listitem>
247     </varlistentry>
248
249     <varlistentry>
250      <term>REFERENCES</term>
251      <listitem>
252       <para>
253        To create a foreign key constraint, it is
254        necessary to have this privilege on both the referencing and
255        referenced columns.  The privilege may be granted for all columns
256        of a table, or just specific columns.
257       </para>
258      </listitem>
259     </varlistentry>
260
261     <varlistentry>
262      <term>TRIGGER</term>
263      <listitem>
264       <para>
265        Allows the creation of a trigger on the specified table.  (See the
266        <xref linkend="sql-createtrigger"> statement.)
267       </para>
268      </listitem>
269     </varlistentry>
270
271     <varlistentry>
272      <term>CREATE</term>
273      <listitem>
274       <para>
275        For databases, allows new schemas to be created within the database.
276       </para>
277       <para>
278        For schemas, allows new objects to be created within the schema.
279        To rename an existing object, you must own the object <emphasis>and</>
280        have this privilege for the containing schema.
281       </para>
282       <para>
283        For tablespaces, allows tables, indexes, and temporary files to be
284        created within the tablespace, and allows databases to be created that
285        have the tablespace as their default tablespace.  (Note that revoking
286        this privilege will not alter the placement of existing objects.)
287       </para>
288      </listitem>
289     </varlistentry>
290
291     <varlistentry>
292      <term>CONNECT</term>
293      <listitem>
294       <para>
295        Allows the user to connect to the specified database.  This
296        privilege is checked at connection startup (in addition to checking
297        any restrictions imposed by <filename>pg_hba.conf</>).
298       </para>
299      </listitem>
300     </varlistentry>
301
302     <varlistentry>
303      <term>TEMPORARY</term>
304      <term>TEMP</term>
305      <listitem>
306       <para>
307        Allows temporary tables to be created while using the specified database.
308       </para>
309      </listitem>
310     </varlistentry>
311
312     <varlistentry>
313      <term>EXECUTE</term>
314      <listitem>
315       <para>
316        Allows the use of the specified function and the use of any
317        operators that are implemented on top of the function.  This is
318        the only type of privilege that is applicable to functions.
319        (This syntax works for aggregate functions, as well.)
320       </para>
321      </listitem>
322     </varlistentry>
323
324     <varlistentry>
325      <term>USAGE</term>
326      <listitem>
327       <para>
328        For procedural languages, allows the use of the specified language for
329        the creation of functions in that language.  This is the only type
330        of privilege that is applicable to procedural languages.
331       </para>
332       <para>
333        For schemas, allows access to objects contained in the specified
334        schema (assuming that the objects' own privilege requirements are
335        also met).  Essentially this allows the grantee to <quote>look up</>
336        objects within the schema.  Without this permission, it is still
337        possible to see the object names, e.g. by querying the system tables.
338        Also, after revoking this permission, existing backends might have
339        statements that have previously performed this lookup, so this is not
340        a completely secure way to prevent object access.
341       </para>
342       <para>
343        For sequences, this privilege allows the use of the
344        <function>currval</function> and <function>nextval</function> functions.
345       </para>
346       <para>
347        For types and domains, this privilege allow the use of the type or
348        domain in the creation of tables, functions, and other schema objects.
349        (Note that it does not control general <quote>usage</quote> of the type,
350        such as values of the type appearing in queries.  It only prevents
351        objects from being created that depend on the type.  The main purpose of
352        the privilege is controlling which users create dependencies on a type,
353        which could prevent the owner from changing the type later.)
354       </para>
355       <para>
356        For foreign-data wrappers, this privilege enables the grantee
357        to create new servers using that foreign-data wrapper.
358       </para>
359       <para>
360        For servers, this privilege enables the grantee to create,
361        alter, and drop his own user's user mappings associated with
362        that server.  Also, it enables the grantee to query the options
363        of the server and associated user mappings.
364       </para>
365      </listitem>
366     </varlistentry>
367
368     <varlistentry>
369      <term>ALL PRIVILEGES</term>
370      <listitem>
371       <para>
372        Grant all of the available privileges at once.
373        The <literal>PRIVILEGES</literal> key word is optional in
374        <productname>PostgreSQL</productname>, though it is required by
375        strict SQL.
376       </para>
377      </listitem>
378     </varlistentry>
379    </variablelist>
380
381    The privileges required by other commands are listed on the
382    reference page of the respective command.
383   </para>
384  </refsect2>
385
386  <refsect2 id="sql-grant-description-roles">
387   <title>GRANT on Roles</title>
388
389   <para>
390    This variant of the <command>GRANT</command> command grants membership
391    in a role to one or more other roles.  Membership in a role is significant
392    because it conveys the privileges granted to a role to each of its
393    members.
394   </para>
395
396   <para>
397    If <literal>WITH ADMIN OPTION</literal> is specified, the member can
398    in turn grant membership in the role to others, and revoke membership
399    in the role as well.  Without the admin option, ordinary users cannot do
400    that.  However,
401    database superusers can grant or revoke membership in any role to anyone.
402    Roles having <literal>CREATEROLE</> privilege can grant or revoke
403    membership in any role that is not a superuser.
404   </para>
405
406   <para>
407    Unlike the case with privileges, membership in a role cannot be granted
408    to <literal>PUBLIC</>.  Note also that this form of the command does not
409    allow the noise word <literal>GROUP</>.
410   </para>
411  </refsect2>
412  </refsect1>
413
414
415  <refsect1 id="SQL-GRANT-notes">
416   <title>Notes</title>
417
418    <para>
419     The <xref linkend="sql-revoke"> command is used
420     to revoke access privileges.
421    </para>
422
423    <para>
424     Since <productname>PostgreSQL</productname> 8.1, the concepts of users and
425     groups have been unified into a single kind of entity called a role.
426     It is therefore no longer necessary to use the keyword <literal>GROUP</>
427     to identify whether a grantee is a user or a group.  <literal>GROUP</>
428     is still allowed in the command, but it is a noise word.
429    </para>
430
431    <para>
432     A user may perform <command>SELECT</>, <command>INSERT</>, etc. on a
433     column if he holds that privilege for either the specific column or
434     its whole table.  Granting the privilege at the table level and then
435     revoking it for one column will not do what you might wish: the
436     table-level grant is unaffected by a column-level operation.
437    </para>
438
439    <para>
440     When a non-owner of an object attempts to <command>GRANT</> privileges
441     on the object, the command will fail outright if the user has no
442     privileges whatsoever on the object.  As long as some privilege is
443     available, the command will proceed, but it will grant only those
444     privileges for which the user has grant options.  The <command>GRANT ALL
445     PRIVILEGES</> forms will issue a warning message if no grant options are
446     held, while the other forms will issue a warning if grant options for
447     any of the privileges specifically named in the command are not held.
448     (In principle these statements apply to the object owner as well, but
449     since the owner is always treated as holding all grant options, the
450     cases can never occur.)
451    </para>
452
453    <para>
454     It should be noted that database superusers can access
455     all objects regardless of object privilege settings.  This
456     is comparable to the rights of <literal>root</> in a Unix system.
457     As with <literal>root</>, it's unwise to operate as a superuser
458     except when absolutely necessary.
459    </para>
460
461    <para>
462     If a superuser chooses to issue a <command>GRANT</> or <command>REVOKE</>
463     command, the command is performed as though it were issued by the
464     owner of the affected object.  In particular, privileges granted via
465     such a command will appear to have been granted by the object owner.
466     (For role membership, the membership appears to have been granted
467     by the containing role itself.)
468    </para>
469
470    <para>
471     <command>GRANT</> and <command>REVOKE</> can also be done by a role
472     that is not the owner of the affected object, but is a member of the role
473     that owns the object, or is a member of a role that holds privileges
474     <literal>WITH GRANT OPTION</literal> on the object.  In this case the
475     privileges will be recorded as having been granted by the role that
476     actually owns the object or holds the privileges
477     <literal>WITH GRANT OPTION</literal>.  For example, if table
478     <literal>t1</> is owned by role <literal>g1</>, of which role
479     <literal>u1</> is a member, then <literal>u1</> can grant privileges
480     on <literal>t1</> to <literal>u2</>, but those privileges will appear
481     to have been granted directly by <literal>g1</>.  Any other member
482     of role <literal>g1</> could revoke them later.
483    </para>
484
485    <para>
486     If the role executing <command>GRANT</> holds the required privileges
487     indirectly via more than one role membership path, it is unspecified
488     which containing role will be recorded as having done the grant.  In such
489     cases it is best practice to use <command>SET ROLE</> to become the
490     specific role you want to do the <command>GRANT</> as.
491    </para>
492
493    <para>
494     Granting permission on a table does not automatically extend
495     permissions to any sequences used by the table, including
496     sequences tied to <type>SERIAL</> columns.  Permissions on
497     sequences must be set separately.
498    </para>
499
500    <para>
501     Use <xref linkend="app-psql">'s <command>\dp</command> command
502     to obtain information about existing privileges for tables and
503     columns.  For example:
504 <programlisting>
505 =&gt; \dp mytable
506                               Access privileges
507  Schema |  Name   | Type  |   Access privileges   | Column access privileges 
508 --------+---------+-------+-----------------------+--------------------------
509  public | mytable | table | miriam=arwdDxt/miriam | col1:
510                           : =r/miriam             :   miriam_rw=rw/miriam
511                           : admin=arw/miriam        
512 (1 row)
513 </programlisting>
514     The entries shown by <command>\dp</command> are interpreted thus:
515 <literallayout class="monospaced">
516 rolename=xxxx -- privileges granted to a role
517         =xxxx -- privileges granted to PUBLIC
518
519             r -- SELECT ("read")
520             w -- UPDATE ("write")
521             a -- INSERT ("append")
522             d -- DELETE
523             D -- TRUNCATE
524             x -- REFERENCES
525             t -- TRIGGER
526             X -- EXECUTE
527             U -- USAGE
528             C -- CREATE
529             c -- CONNECT
530             T -- TEMPORARY
531       arwdDxt -- ALL PRIVILEGES (for tables, varies for other objects)
532             * -- grant option for preceding privilege
533
534         /yyyy -- role that granted this privilege
535 </literallayout>
536
537     The above example display would be seen by user <literal>miriam</> after
538     creating table <literal>mytable</> and doing:
539
540 <programlisting>
541 GRANT SELECT ON mytable TO PUBLIC;
542 GRANT SELECT, UPDATE, INSERT ON mytable TO admin;
543 GRANT SELECT (col1), UPDATE (col1) ON mytable TO miriam_rw;
544 </programlisting>
545    </para>
546
547    <para>
548     For non-table objects there are other <command>\d</> commands
549     that can display their privileges.
550    </para>
551
552    <para>
553     If the <quote>Access privileges</> column is empty for a given object,
554     it means the object has default privileges (that is, its privileges column
555     is null).  Default privileges always include all privileges for the owner,
556     and can include some privileges for <literal>PUBLIC</> depending on the
557     object type, as explained above.  The first <command>GRANT</> or
558     <command>REVOKE</> on an object
559     will instantiate the default privileges (producing, for example,
560     <literal>{miriam=arwdDxt/miriam}</>) and then modify them per the
561     specified request.  Similarly, entries are shown in <quote>Column access
562     privileges</> only for columns with nondefault privileges.
563     (Note: for this purpose, <quote>default privileges</> always means the
564     built-in default privileges for the object's type.  An object whose
565     privileges have been affected by an <command>ALTER DEFAULT PRIVILEGES</>
566     command will always be shown with an explicit privilege entry that
567     includes the effects of the <command>ALTER</>.)
568    </para>
569
570    <para>
571     Notice that the owner's implicit grant options are not marked in the
572     access privileges display.  A <literal>*</> will appear only when
573     grant options have been explicitly granted to someone.
574    </para>
575  </refsect1>
576
577  <refsect1 id="sql-grant-examples">
578   <title>Examples</title>
579
580   <para>
581    Grant insert privilege to all users on table <literal>films</literal>:
582
583 <programlisting>
584 GRANT INSERT ON films TO PUBLIC;
585 </programlisting>
586   </para>
587
588   <para>
589    Grant all available privileges to user <literal>manuel</literal> on view
590    <literal>kinds</literal>:
591
592 <programlisting>
593 GRANT ALL PRIVILEGES ON kinds TO manuel;
594 </programlisting>
595
596    Note that while the above will indeed grant all privileges if executed by a
597    superuser or the owner of <literal>kinds</literal>, when executed by someone
598    else it will only grant those permissions for which the someone else has
599    grant options.
600   </para>
601
602   <para>
603    Grant membership in role <literal>admins</> to user <literal>joe</>:
604
605 <programlisting>
606 GRANT admins TO joe;
607 </programlisting></para>
608  </refsect1>
609
610  <refsect1 id="sql-grant-compatibility">
611   <title>Compatibility</title>
612
613    <para>
614     According to the SQL standard, the <literal>PRIVILEGES</literal>
615     key word in <literal>ALL PRIVILEGES</literal> is required.  The
616     SQL standard does not support setting the privileges on more than
617     one object per command.
618    </para>
619
620    <para>
621     <productname>PostgreSQL</productname> allows an object owner to revoke his
622     own ordinary privileges: for example, a table owner can make the table
623     read-only to himself by revoking his own <literal>INSERT</>,
624     <literal>UPDATE</>, <literal>DELETE</>, and <literal>TRUNCATE</>
625     privileges.  This is not possible according to the SQL standard.  The
626     reason is that <productname>PostgreSQL</productname> treats the owner's
627     privileges as having been granted by the owner to himself; therefore he
628     can revoke them too.  In the SQL standard, the owner's privileges are
629     granted by an assumed entity <quote>_SYSTEM</>.  Not being
630     <quote>_SYSTEM</>, the owner cannot revoke these rights.
631    </para>
632
633    <para>
634     According to the SQL standard, grant options can be granted to
635     <literal>PUBLIC</literal>; PostgreSQL only supports granting grant options
636     to roles.
637    </para>
638
639    <para>
640     The SQL standard provides for a <literal>USAGE</literal> privilege
641     on other kinds of objects: character sets, collations,
642     translations.
643    </para>
644
645    <para>
646     In the SQL standard, sequences only have a <literal>USAGE</literal>
647     privilege, which controls the use of the <literal>NEXT VALUE FOR</literal>
648     expression, which is equivalent to the
649     function <function>nextval</function> in PostgreSQL.  The sequence
650     privileges <literal>SELECT</literal> and <literal>UPDATE</literal> are
651     PostgreSQL extensions.  The application of the
652     sequence <literal>USAGE</literal> privilege to
653     the <literal>currval</literal> function is also a PostgreSQL extension (as
654     is the function itself).
655    </para>
656
657    <para>
658     Privileges on databases, tablespaces, schemas, and languages are
659     <productname>PostgreSQL</productname> extensions.
660    </para>
661  </refsect1>
662
663
664  <refsect1>
665   <title>See Also</title>
666
667   <simplelist type="inline">
668    <member><xref linkend="sql-revoke"></member>
669    <member><xref linkend="sql-alterdefaultprivileges"></member>
670   </simplelist>
671  </refsect1>
672
673 </refentry>