title: Difference between ALTER ROLE WITH CREATEDB and GRANT CREATE ON TABLESPACE
body: <p>Coming from MySQL and not knowing about ROLEs I absentmindedly tried this</p>
  
  <pre><code>GRANT CREATE ON TABLESPACE pg_default TO username;
  </code></pre>
  
  <p>It didn't have the desired effect. The command that I was looking for was:</p>
  
  <pre><code>ALTER ROLE username WITH CREATEDB;
  </code></pre>
  
  <p>But what's the difference precisely? Does giving someone the CREATEDB role implicitly give them CREATE ON TABLESPACE ...? Is there a table where I can see all this?</p>
  
  <p>From the <a href="http://www.postgresql.org/docs/8.4/static/sql-grant.html" rel="noreferrer">docs</a>, GRANT CREATE ON TABLESPACE means (my emphasis):</p>
  
  <blockquote>
    <p>For tablespaces, allows tables,
    indexes, and temporary files to be
    created within the tablespace, and
    <strong>allows databases to be
    created</strong> that have the
    tablespace as their default
    tablespace. (Note that revoking this
    privilege will not alter the placement
    of existing objects.)</p>
  </blockquote>