]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/grant.sgml
Add support for piping COPY to/from an external program.
[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_name</replaceable> [, ...] )
31     [, ...] | ALL [ PRIVILEGES ] ( <replaceable class="PARAMETER">column_name</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 foreign
361        tables using the server, and also to create, alter, or drop his own
362        user's user mappings associated with that server.
363       </para>
364      </listitem>
365     </varlistentry>
366
367     <varlistentry>
368      <term>ALL PRIVILEGES</term>
369      <listitem>
370       <para>
371        Grant all of the available privileges at once.
372        The <literal>PRIVILEGES</literal> key word is optional in
373        <productname>PostgreSQL</productname>, though it is required by
374        strict SQL.
375       </para>
376      </listitem>
377     </varlistentry>
378    </variablelist>
379
380    The privileges required by other commands are listed on the
381    reference page of the respective command.
382   </para>
383  </refsect2>
384
385  <refsect2 id="sql-grant-description-roles">
386   <title>GRANT on Roles</title>
387
388   <para>
389    This variant of the <command>GRANT</command> command grants membership
390    in a role to one or more other roles.  Membership in a role is significant
391    because it conveys the privileges granted to a role to each of its
392    members.
393   </para>
394
395   <para>
396    If <literal>WITH ADMIN OPTION</literal> is specified, the member can
397    in turn grant membership in the role to others, and revoke membership
398    in the role as well.  Without the admin option, ordinary users cannot do
399    that.  However,
400    database superusers can grant or revoke membership in any role to anyone.
401    Roles having <literal>CREATEROLE</> privilege can grant or revoke
402    membership in any role that is not a superuser.
403   </para>
404
405   <para>
406    Unlike the case with privileges, membership in a role cannot be granted
407    to <literal>PUBLIC</>.  Note also that this form of the command does not
408    allow the noise word <literal>GROUP</>.
409   </para>
410  </refsect2>
411  </refsect1>
412
413
414  <refsect1 id="SQL-GRANT-notes">
415   <title>Notes</title>
416
417    <para>
418     The <xref linkend="sql-revoke"> command is used
419     to revoke access privileges.
420    </para>
421
422    <para>
423     Since <productname>PostgreSQL</productname> 8.1, the concepts of users and
424     groups have been unified into a single kind of entity called a role.
425     It is therefore no longer necessary to use the keyword <literal>GROUP</>
426     to identify whether a grantee is a user or a group.  <literal>GROUP</>
427     is still allowed in the command, but it is a noise word.
428    </para>
429
430    <para>
431     A user may perform <command>SELECT</>, <command>INSERT</>, etc. on a
432     column if he holds that privilege for either the specific column or
433     its whole table.  Granting the privilege at the table level and then
434     revoking it for one column will not do what you might wish: the
435     table-level grant is unaffected by a column-level operation.
436    </para>
437
438    <para>
439     When a non-owner of an object attempts to <command>GRANT</> privileges
440     on the object, the command will fail outright if the user has no
441     privileges whatsoever on the object.  As long as some privilege is
442     available, the command will proceed, but it will grant only those
443     privileges for which the user has grant options.  The <command>GRANT ALL
444     PRIVILEGES</> forms will issue a warning message if no grant options are
445     held, while the other forms will issue a warning if grant options for
446     any of the privileges specifically named in the command are not held.
447     (In principle these statements apply to the object owner as well, but
448     since the owner is always treated as holding all grant options, the
449     cases can never occur.)
450    </para>
451
452    <para>
453     It should be noted that database superusers can access
454     all objects regardless of object privilege settings.  This
455     is comparable to the rights of <literal>root</> in a Unix system.
456     As with <literal>root</>, it's unwise to operate as a superuser
457     except when absolutely necessary.
458    </para>
459
460    <para>
461     If a superuser chooses to issue a <command>GRANT</> or <command>REVOKE</>
462     command, the command is performed as though it were issued by the
463     owner of the affected object.  In particular, privileges granted via
464     such a command will appear to have been granted by the object owner.
465     (For role membership, the membership appears to have been granted
466     by the containing role itself.)
467    </para>
468
469    <para>
470     <command>GRANT</> and <command>REVOKE</> can also be done by a role
471     that is not the owner of the affected object, but is a member of the role
472     that owns the object, or is a member of a role that holds privileges
473     <literal>WITH GRANT OPTION</literal> on the object.  In this case the
474     privileges will be recorded as having been granted by the role that
475     actually owns the object or holds the privileges
476     <literal>WITH GRANT OPTION</literal>.  For example, if table
477     <literal>t1</> is owned by role <literal>g1</>, of which role
478     <literal>u1</> is a member, then <literal>u1</> can grant privileges
479     on <literal>t1</> to <literal>u2</>, but those privileges will appear
480     to have been granted directly by <literal>g1</>.  Any other member
481     of role <literal>g1</> could revoke them later.
482    </para>
483
484    <para>
485     If the role executing <command>GRANT</> holds the required privileges
486     indirectly via more than one role membership path, it is unspecified
487     which containing role will be recorded as having done the grant.  In such
488     cases it is best practice to use <command>SET ROLE</> to become the
489     specific role you want to do the <command>GRANT</> as.
490    </para>
491
492    <para>
493     Granting permission on a table does not automatically extend
494     permissions to any sequences used by the table, including
495     sequences tied to <type>SERIAL</> columns.  Permissions on
496     sequences must be set separately.
497    </para>
498
499    <para>
500     Use <xref linkend="app-psql">'s <command>\dp</command> command
501     to obtain information about existing privileges for tables and
502     columns.  For example:
503 <programlisting>
504 =&gt; \dp mytable
505                               Access privileges
506  Schema |  Name   | Type  |   Access privileges   | Column access privileges 
507 --------+---------+-------+-----------------------+--------------------------
508  public | mytable | table | miriam=arwdDxt/miriam | col1:
509                           : =r/miriam             :   miriam_rw=rw/miriam
510                           : admin=arw/miriam        
511 (1 row)
512 </programlisting>
513     The entries shown by <command>\dp</command> are interpreted thus:
514 <literallayout class="monospaced">
515 rolename=xxxx -- privileges granted to a role
516         =xxxx -- privileges granted to PUBLIC
517
518             r -- SELECT ("read")
519             w -- UPDATE ("write")
520             a -- INSERT ("append")
521             d -- DELETE
522             D -- TRUNCATE
523             x -- REFERENCES
524             t -- TRIGGER
525             X -- EXECUTE
526             U -- USAGE
527             C -- CREATE
528             c -- CONNECT
529             T -- TEMPORARY
530       arwdDxt -- ALL PRIVILEGES (for tables, varies for other objects)
531             * -- grant option for preceding privilege
532
533         /yyyy -- role that granted this privilege
534 </literallayout>
535
536     The above example display would be seen by user <literal>miriam</> after
537     creating table <literal>mytable</> and doing:
538
539 <programlisting>
540 GRANT SELECT ON mytable TO PUBLIC;
541 GRANT SELECT, UPDATE, INSERT ON mytable TO admin;
542 GRANT SELECT (col1), UPDATE (col1) ON mytable TO miriam_rw;
543 </programlisting>
544    </para>
545
546    <para>
547     For non-table objects there are other <command>\d</> commands
548     that can display their privileges.
549    </para>
550
551    <para>
552     If the <quote>Access privileges</> column is empty for a given object,
553     it means the object has default privileges (that is, its privileges column
554     is null).  Default privileges always include all privileges for the owner,
555     and can include some privileges for <literal>PUBLIC</> depending on the
556     object type, as explained above.  The first <command>GRANT</> or
557     <command>REVOKE</> on an object
558     will instantiate the default privileges (producing, for example,
559     <literal>{miriam=arwdDxt/miriam}</>) and then modify them per the
560     specified request.  Similarly, entries are shown in <quote>Column access
561     privileges</> only for columns with nondefault privileges.
562     (Note: for this purpose, <quote>default privileges</> always means the
563     built-in default privileges for the object's type.  An object whose
564     privileges have been affected by an <command>ALTER DEFAULT PRIVILEGES</>
565     command will always be shown with an explicit privilege entry that
566     includes the effects of the <command>ALTER</>.)
567    </para>
568
569    <para>
570     Notice that the owner's implicit grant options are not marked in the
571     access privileges display.  A <literal>*</> will appear only when
572     grant options have been explicitly granted to someone.
573    </para>
574  </refsect1>
575
576  <refsect1 id="sql-grant-examples">
577   <title>Examples</title>
578
579   <para>
580    Grant insert privilege to all users on table <literal>films</literal>:
581
582 <programlisting>
583 GRANT INSERT ON films TO PUBLIC;
584 </programlisting>
585   </para>
586
587   <para>
588    Grant all available privileges to user <literal>manuel</literal> on view
589    <literal>kinds</literal>:
590
591 <programlisting>
592 GRANT ALL PRIVILEGES ON kinds TO manuel;
593 </programlisting>
594
595    Note that while the above will indeed grant all privileges if executed by a
596    superuser or the owner of <literal>kinds</literal>, when executed by someone
597    else it will only grant those permissions for which the someone else has
598    grant options.
599   </para>
600
601   <para>
602    Grant membership in role <literal>admins</> to user <literal>joe</>:
603
604 <programlisting>
605 GRANT admins TO joe;
606 </programlisting></para>
607  </refsect1>
608
609  <refsect1 id="sql-grant-compatibility">
610   <title>Compatibility</title>
611
612    <para>
613     According to the SQL standard, the <literal>PRIVILEGES</literal>
614     key word in <literal>ALL PRIVILEGES</literal> is required.  The
615     SQL standard does not support setting the privileges on more than
616     one object per command.
617    </para>
618
619    <para>
620     <productname>PostgreSQL</productname> allows an object owner to revoke his
621     own ordinary privileges: for example, a table owner can make the table
622     read-only to himself by revoking his own <literal>INSERT</>,
623     <literal>UPDATE</>, <literal>DELETE</>, and <literal>TRUNCATE</>
624     privileges.  This is not possible according to the SQL standard.  The
625     reason is that <productname>PostgreSQL</productname> treats the owner's
626     privileges as having been granted by the owner to himself; therefore he
627     can revoke them too.  In the SQL standard, the owner's privileges are
628     granted by an assumed entity <quote>_SYSTEM</>.  Not being
629     <quote>_SYSTEM</>, the owner cannot revoke these rights.
630    </para>
631
632    <para>
633     According to the SQL standard, grant options can be granted to
634     <literal>PUBLIC</literal>; PostgreSQL only supports granting grant options
635     to roles.
636    </para>
637
638    <para>
639     The SQL standard provides for a <literal>USAGE</literal> privilege
640     on other kinds of objects: character sets, collations,
641     translations.
642    </para>
643
644    <para>
645     In the SQL standard, sequences only have a <literal>USAGE</literal>
646     privilege, which controls the use of the <literal>NEXT VALUE FOR</literal>
647     expression, which is equivalent to the
648     function <function>nextval</function> in PostgreSQL.  The sequence
649     privileges <literal>SELECT</literal> and <literal>UPDATE</literal> are
650     PostgreSQL extensions.  The application of the
651     sequence <literal>USAGE</literal> privilege to
652     the <literal>currval</literal> function is also a PostgreSQL extension (as
653     is the function itself).
654    </para>
655
656    <para>
657     Privileges on databases, tablespaces, schemas, and languages are
658     <productname>PostgreSQL</productname> extensions.
659    </para>
660  </refsect1>
661
662
663  <refsect1>
664   <title>See Also</title>
665
666   <simplelist type="inline">
667    <member><xref linkend="sql-revoke"></member>
668    <member><xref linkend="sql-alterdefaultprivileges"></member>
669   </simplelist>
670  </refsect1>
671
672 </refentry>