1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>18.3.Privileges</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="user-manag.html" title="Chapter18.Database Roles and Privileges">
<link rel="prev" href="role-attributes.html" title="18.2.Role Attributes">
<link rel="next" href="role-membership.html" title="18.4.Role Membership">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="privileges"></a>18.3.Privileges</h2></div></div></div>
<a name="id657957"></a><a name="id657968"></a><a name="id657979"></a><a name="id657989"></a><p> When an object is created, it is assigned an owner. The
owner is normally the role that executed the creation statement.
For most kinds of objects, the initial state is that only the owner
(or a superuser) can do anything with the object. To allow
other roles to use it, <em class="firstterm">privileges</em> must be
granted.
There are several different kinds of privilege: <code class="literal">SELECT</code>,
<code class="literal">INSERT</code>, <code class="literal">UPDATE</code>, <code class="literal">DELETE</code>,
<code class="literal">RULE</code>, <code class="literal">REFERENCES</code>, <code class="literal">TRIGGER</code>,
<code class="literal">CREATE</code>, <code class="literal">TEMPORARY</code>, <code class="literal">EXECUTE</code>,
and <code class="literal">USAGE</code>. For more
information on the different types of privileges supported by
<span class="productname">PostgreSQL</span>, see the
<a href="sql-grant.html">GRANT</a> reference page.
</p>
<p> To assign privileges, the <code class="command">GRANT</code> command is
used. So, if <code class="literal">joe</code> is an existing role, and
<code class="literal">accounts</code> is an existing table, the privilege to
update the table can be granted with
</p>
<pre class="programlisting">GRANT UPDATE ON accounts TO joe;</pre>
<p>
The special name <code class="literal">PUBLIC</code> can
be used to grant a privilege to every role on the system. Writing
<code class="literal">ALL</code> in place of a specific privilege specifies that all
privileges that apply to the object will be granted.
</p>
<p> To revoke a privilege, use the fittingly named
<a href="sql-revoke.html">REVOKE</a> command:
</p>
<pre class="programlisting">REVOKE ALL ON accounts FROM PUBLIC;</pre>
<p>
</p>
<p> The special privileges of an object's owner (i.e., the right to modify
or destroy the object) are always implicit in being the owner,
and cannot be granted or revoked. But the owner can choose
to revoke his own ordinary privileges, for example to make a
table read-only for himself as well as others.
</p>
<p> An object can be assigned to a new owner with an <code class="command">ALTER</code>
command of the appropriate kind for the object. Superusers can always do
this; ordinary roles can only do it if they are both the current owner
of the object (or a member of the owning role) and a member of the new
owning role.
</p>
</div></body>
</html>
|