<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Postgres OnLine Journal - q&amp;a</title>
    <link>http://www.postgresonline.com/journal/</link>
    <description>an In depth look at the PostgreSQL open source database</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.4.1 - http://www.s9y.org/</generator>
    <pubDate>Tue, 30 Apr 2013 17:45:46 GMT</pubDate>

    <image>
        <url>http://www.postgresonline.com/journal/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Postgres OnLine Journal - q&amp;a - an In depth look at the PostgreSQL open source database</title>
        <link>http://www.postgresonline.com/journal/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Which PostGIS should you use with PostgreSQL 9.3</title>
    <link>http://www.postgresonline.com/journal/archives/303-Which-PostGIS-should-you-use-with-PostgreSQL-9.3.html</link>
            <category>9.3</category>
            <category>postgis</category>
            <category>postgresql versions</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/303-Which-PostGIS-should-you-use-with-PostgreSQL-9.3.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=303</wfw:comment>

    <slash:comments>4</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=303</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;PostgreSQL 9.3 will be coming out in beta soon and with that, some who want to experiment with both PostGIS and PostgreSQL 9.3 have asked if they can use PostGIS 2.0.  The answer is &lt;b&gt;NO&lt;/b&gt;. A lot of major changes happened in PostgreSQL 9.3 that required us to patch up upcoming PostGIS 2.1.  These changes were not backported to 2.0 and I personally do not plan to back-port them unless lightning strikes me and I escape unscathed, a big wad of cash falls from the sky, or for some reason we can&#039;t make the 2.1 cut before 9.3 comes out. So if you are planning to experiment with PostgreSQL 9.3, &lt;b&gt;PLEASE use PostGIS 2.1 development branch&lt;/b&gt;.  I will try to make sure we release 2.1 before PostgreSQL 9.3 comes out even if I have to resort to hitting some people over the head with a rubber bat :).&lt;/p&gt;

&lt;p&gt;If ever in doubt what versions of PostGIS works with what versions of PostgreSQL /GEOS / GDAL, please refer to the matrix that we try to keep up to date. 
&lt;a href=&quot;http://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS&quot; target=&quot;_blank&quot;&gt;http://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now some people might say &amp;quot;Isn&#039;t it cruel  not to support PostGIS 2.0 for 9.3&amp;quot;, and my answer is &amp;quot;it&#039;s crueler to&amp;quot;.  The reason is simple.  We have limited bandwidth for testing permutations of things and the more permutations of things we support, the dirtier our code base becomes making it harder to maintain and also the less time we can devote to properly testing each permutation.  I&#039;d rather say we don&#039;t support something than to do a half-hearted job of supporting all. 
On a slightly different, but also pragmatic note, package maintainers (except for windows maintainers :)) generally only carry one version of PostGIS per version of PostgreSQL, and I&#039;d rather users getting from packages  see our best foot than a two year old aging foot.&lt;/p&gt;

&lt;p&gt;Note: that going from PostGIS 2.0 to 2.1 is a soft upgrade so you can install 2.1 on your existing PostgreSQL 9.2 without dump restore and then you should be able to pg_upgrade over to 9.3 if your database is  too big to dump restore.&lt;/p&gt;

 
    </content:encoded>

    <pubDate>Tue, 30 Apr 2013 00:30:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/303-guid.html</guid>
    <category>postgis</category>
<category>postgresql 9.3</category>

</item>
<item>
    <title>Should I install using PostGIS extension</title>
    <link>http://www.postgresonline.com/journal/archives/295-Should-I-install-using-PostGIS-extension.html</link>
            <category>postgis</category>
            <category>postgresql versions</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/295-Should-I-install-using-PostGIS-extension.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=295</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=295</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;&lt;em&gt;Should I install using PostGIS extension?&lt;/em&gt; is an FAQ that comes up quite a bit in PostGIS circles and unfortunately askers get mixed answers.
In &lt;a href=&quot;http://www.bostongis.com/blog/index.php?/archives/187-How-to-upgrade-your-database-to-PostGIS-2.0-let-me-count-the-ways.html&quot; target=&quot;_blank&quot;&gt;How to upgrade your database to PostGIS 2.0&lt;/a&gt;
we covered WHY you should use extensions.  In this article I&#039;ll use my &lt;a href=&quot;http://en.wikipedia.org/wiki/Lincoln%E2%80%93Douglas_debate&quot; target=&quot;_blank&quot;&gt;Lincoln-Douglas debate&lt;/a&gt; skills to argue why you shouldn&#039;t.
Keep in mind that I put a great deal of effort in fitting PostGIS extensions
into the existing PostGIS build structure and I eat my own dogfood, so I might be a little biased and a poor defender of the counter argument.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/295-Should-I-install-using-PostGIS-extension.html#extended&quot;&gt;Continue reading &quot;Should I install using PostGIS extension&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Wed, 06 Mar 2013 16:37:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/295-guid.html</guid>
    <category>extensions</category>
<category>postgis</category>

</item>
<item>
    <title>How to add database name to log output</title>
    <link>http://www.postgresonline.com/journal/archives/291-How-to-add-database-name-to-log-output.html</link>
            <category>beginner</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/291-How-to-add-database-name-to-log-output.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=291</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=291</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;PostgreSQL allows you to customize statement logging in numerous ways. You can globally set the level of logging you want at both the postgresql.conf (that will affect all databases) or at the database level using the various &lt;code&gt;log_statement*&lt;/code&gt; variables.   Most of these
are documented in &lt;a href=&quot;http://www.postgresql.org/docs/current/interactive/runtime-config-logging.html&quot; target=&quot;_blank&quot;&gt;runtime config logging&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For this brief article, we&#039;ll talk about the &lt;a href=&quot;http://www.postgresql.org/docs/current/interactive/runtime-config-logging.html#GUC-LOG-LINE-PREFIX&quot;&gt;&lt;b&gt;log_line_prefix&lt;/b&gt;&lt;/a&gt; variable. By default this variable is very minimalistic and just prefixes the log lines with the date time of the statement.  If you have just one database (like the way Oracle runs) this is not a big deal,
but if you are like us and run several databases on one PostgreSQL instance, it would be nice to as part of the prefix include the database name.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/291-How-to-add-database-name-to-log-output.html#extended&quot;&gt;Continue reading &quot;How to add database name to log output&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 08 Feb 2013 17:06:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/291-guid.html</guid>
    <category>logging</category>

</item>
<item>
    <title>How to map MS Access auto number to PostgreSQL serial</title>
    <link>http://www.postgresonline.com/journal/archives/290-How-to-map-MS-Access-auto-number-to-PostgreSQL-serial.html</link>
            <category>intermediate</category>
            <category>ms access</category>
            <category>other dbms</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/290-How-to-map-MS-Access-auto-number-to-PostgreSQL-serial.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=290</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=290</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;This exercise is a continuation of our &lt;a href=&quot;http://www.postgresonline.com/journal/archives/288-How-to-bulk-export-tables-from-MS-Access.html&quot; target=&quot;_blank&quot;&gt;How to bulk export tables from MS Access&lt;/a&gt; and &lt;a href=&quot;http://www.postgresonline.com/journal/archives/289-How-to-recreate-MS-Access-primary-keys-and-indexes-in-PG.html&quot; target=&quot;_blank&quot;&gt;How to recreate MS Access primary keys and indexes in PostgreSQL&lt;/a&gt;. As mentioned in the first article, when you use the built-in export feature of MS Access, it exports autonumber fields as integers instead of the more appropriate PostgreSQL pseudo &lt;b&gt;serial&lt;/b&gt; type. &lt;/p&gt;
&lt;p&gt;The serial type in PostgreSQL is not really a type though, so this behavior is expected. The serial type is really short-hand for defining an integer column and a corresponding sequence object
with a specific naming convention and setting the default value to the next value of the sequence.  So this is what we will do in this exercise after we have already exported our data to PostgreSQL.  The script we are about to demonstrate will generate an sQL script containing all the &lt;code&gt;CREATE SEQUENCE&lt;/code&gt;, and &lt;code&gt;ALTER TABLE ALTER COLUMN SET DEFAULT ..&lt;/code&gt; needed to convert our integer column to a serial column.&lt;/p&gt;

&lt;p&gt;As a side note, Mark mentioned a similar approach to what we&#039;ve been describing here, but builds all the table , key structures utilizing python.  You can check out the python script
at &lt;a href=&quot;http://code.activestate.com/recipes/52267-reverse-engineer-ms-accessjet-databases/&quot; target=&quot;_blank&quot;&gt;http://code.activestate.com/recipes/52267-reverse-engineer-ms-accessjet-databases&lt;/a&gt;&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/290-How-to-map-MS-Access-auto-number-to-PostgreSQL-serial.html#extended&quot;&gt;Continue reading &quot;How to map MS Access auto number to PostgreSQL serial&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 28 Jan 2013 17:56:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/290-guid.html</guid>
    <category>migration</category>
<category>msaccess</category>
<category>python</category>
<category>sequence</category>
<category>serial</category>

</item>
<item>
    <title>How to recreate MS Access primary keys and indexes in PG</title>
    <link>http://www.postgresonline.com/journal/archives/289-How-to-recreate-MS-Access-primary-keys-and-indexes-in-PG.html</link>
            <category>intermediate</category>
            <category>ms access</category>
            <category>mysql</category>
            <category>oracle</category>
            <category>other dbms</category>
            <category>q&amp;a</category>
            <category>sql server</category>
    
    <comments>http://www.postgresonline.com/journal/archives/289-How-to-recreate-MS-Access-primary-keys-and-indexes-in-PG.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=289</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=289</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;This exercise is a continuation of our &lt;a href=&quot;http://www.postgresonline.com/journal/archives/288-How-to-bulk-export-tables-from-MS-Access.html&quot; target=&quot;_blank&quot;&gt;How to bulk export tables from MS Access&lt;/a&gt;. Now while this approach will work for other databases besides PostgreSQL, you&#039;ll probably need to fiddle with the subroutine to make it work for some other databases.  PostgreSQL is fairly ANSI-SQL standard so not too much fiddling should be required to port to SQL Server, MySQL, Oracle etc.&lt;/p&gt;

&lt;p&gt;Unlike the prior Visual basic subroutine we showed that exports the tables, this just creates an SQL script that you run on the already created PostgreSQL database that contains the exported data. We didn&#039;t test the quote option though we coded it in the subroutine, since like we said we hate having to quote fields. If perchance you are one of those folks that likes to put spaces in your field names to make it more englishy, then you&#039;ll need to quote or revise the other routine to convert your spaces to _ or some other thing.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/289-How-to-recreate-MS-Access-primary-keys-and-indexes-in-PG.html#extended&quot;&gt;Continue reading &quot;How to recreate MS Access primary keys and indexes in PG&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Sun, 27 Jan 2013 13:49:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/289-guid.html</guid>
    <category>migration</category>
<category>msaccess</category>

</item>
<item>
    <title>How to bulk export tables from MS Access</title>
    <link>http://www.postgresonline.com/journal/archives/288-How-to-bulk-export-tables-from-MS-Access.html</link>
            <category>intermediate</category>
            <category>ms access</category>
            <category>other dbms</category>
            <category>q&amp;a</category>
            <category>sql server</category>
    
    <comments>http://www.postgresonline.com/journal/archives/288-How-to-bulk-export-tables-from-MS-Access.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=288</wfw:comment>

    <slash:comments>6</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=288</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;Despite all the nasty things people say about MS Access, it does have fairly database agnostic, easy to use import and export tools and a not too shabby query wizard and query tool.  But of course, it&#039;s not a server side database so at a certain point won&#039;t scale for database storage. You can still use it as a front-end to a server-side database such as PostgreSQL or SQL Server. So once you outgrow it for data storage, you&#039;ll probably want a quick way to export your data out.  Unfortunately, well at least in the 2003 version, while you can bulk link tables from an ODBC connection, you can only export one table at a time using the &quot;select table&quot; right-click export. In this article we&#039;ll show a quick and dirty export MS Access Visual basic sub routine we use to export all tables. This we&#039;ve only tested on MS Access 2003, so if you are using higher, you might need to customize it a bit. This script should work fine for exporting to any database connection with modification of the connection string.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/288-How-to-bulk-export-tables-from-MS-Access.html#extended&quot;&gt;Continue reading &quot;How to bulk export tables from MS Access&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Sun, 27 Jan 2013 13:36:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/288-guid.html</guid>
    <category>migration</category>
<category>msaccess</category>

</item>
<item>
    <title>Searching for phrases embedded in stored function and procedures</title>
    <link>http://www.postgresonline.com/journal/archives/278-Searching-for-phrases-embedded-in-stored-function-and-procedures.html</link>
            <category>intermediate</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/278-Searching-for-phrases-embedded-in-stored-function-and-procedures.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=278</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=278</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;&lt;b&gt;Issue:&lt;/b&gt; Ever had the situation where you decided to delete a table or some other function or type but you weren&#039;t absolutely sure if other functions in the database depended on these.
For things like tables and views that depend on a function, type or other table/view, PostgreSQL won&#039;t allow you to delete the dependency object without doing a drop cascade.
For stored procedures though, while it will prevent you from deleting a dependency type if the function returns or takes as input the object to be deleted, it doesn&#039;t save you if the body of the function references these objects. This dependency information is not always known and in fact may be dynamic with dynamically generated sql or schema path settings.
So how do you inspect functions for usage of other items? &lt;/p&gt;

&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt;  
PostgreSQL has a table called &lt;em&gt;pg_catalog.pg_proc&lt;/em&gt; which stores the source code of functions (non-C) in the  &lt;em&gt;prosrc&lt;/em&gt; column. &lt;/p&gt;
&lt;p&gt;So lets say you had a table called &lt;em&gt;employees&lt;/em&gt; you want to get rid of or simply rename, to find out all functions that reference the term &amp;quot;employees&amp;quot;, you would do something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SELECT proname, proargnames, prosrc 
 FROM pg_proc
 WHERE prosrc ILIKE &#039;%employees%&#039;;&lt;/code&gt;
&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Mon, 12 Nov 2012 17:59:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/278-guid.html</guid>
    
</item>
<item>
    <title>Finding contiguous primary keys</title>
    <link>http://www.postgresonline.com/journal/archives/255-Finding-contiguous-primary-keys.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>9.2</category>
            <category>intermediate</category>
            <category>postgresql versions</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/255-Finding-contiguous-primary-keys.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=255</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=255</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;I recently had the need to figure out which ranges of my keys were contiguously numbered.  The related exercise is finding gaps in data as well.
Reasons might be because you need to determine what data did not get copied or what records got deleted.  There are lots of ways of accomplishing this, but this is the 
first that came to mind.  This approach uses window aggregates &lt;code&gt;lead&lt;/code&gt; function and common table expressions, so requires PostgreSQL 8.4+&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/255-Finding-contiguous-primary-keys.html#extended&quot;&gt;Continue reading &quot;Finding contiguous primary keys&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 08 Jun 2012 16:29:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/255-guid.html</guid>
    <category>common table expressions</category>
<category>cte</category>
<category>except</category>
<category>window</category>
<category>window functions</category>

</item>
<item>
    <title>True or False every which way</title>
    <link>http://www.postgresonline.com/journal/archives/241-True-or-False-every-which-way.html</link>
            <category>intermediate</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/241-True-or-False-every-which-way.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=241</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=241</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;PostgreSQL has aggregate functions called &lt;b&gt;bool_and&lt;/b&gt; and &lt;b&gt;bool_or&lt;/b&gt; which it&#039;s had for as far back as I can remember.
What do they do? given rows of premises (things that resolve to booleans), &lt;em&gt;bool_and&lt;/em&gt; will return true if all of the premises are true.  Similarly &lt;b&gt;bool_or&lt;/b&gt;
will return true if any of the premises in the set of rows is true.  What if however your boolean expressions are not in rows, but instead passed in
as a sequence of arbitrary statements of questionable fact.  We want a function like bool_or or bool_and that takes an arbitrary number of boolean arguments.  Are there functions
that fit the bill.  Indeed there are, but they don&#039;t scream out and say &lt;em&gt;I work with booleans&lt;/em&gt; because they fit into a class of function we
discussed in &lt;a href=&quot;http://www.postgresonline.com/journal/archives/239-The-wonders-of-Any-Element.html&quot; target=&quot;_blank&quot;&gt;The wonders of Any Element&lt;/a&gt; and that also happen to be &lt;a href=&quot;http://www.postgresonline.com/journal/archives/211-Variadic-Functions-in-PostgreSQL.html&quot; target=&quot;_blank&quot;&gt;variadic&lt;/a&gt; functions.
These are none other than
&lt;b&gt;greatest&lt;/b&gt; and &lt;b&gt;least&lt;/b&gt; and they are old timer functions that you can find in most versions of PostgreSQL.  We&#039;ll demonstrate how to use
all 4 with booleans in this article. It must be said that greatest and least are much more useful when applied to other data types like dates
and numbers, but we were amused at the parallel with booleans.&lt;/p&gt;

&lt;div style=&#039;background-color:yellow&#039;&gt;&lt;b&gt;Side note:&lt;/b&gt; we&#039;ve started to write our book on PostgreSQL that will be published by O&#039;Reilly.  We hope to finish this book within the next 5-7 months but have preliminary e-Book drafts before then for early purchasers to scan.
The focus of the book will be PostgreSQL 9.1 with some highlights the upcoming PostgreSQL 9.2.  Of course oldie but goodie topics are  in the book too. It&#039;s a thrill to be writing again.&lt;/div&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/241-True-or-False-every-which-way.html#extended&quot;&gt;Continue reading &quot;True or False every which way&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Wed, 25 Jan 2012 15:55:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/241-guid.html</guid>
    <category>aggregates</category>
<category>anyelement</category>
<category>bool_and</category>
<category>bool_or</category>
<category>greatst</category>
<category>least</category>

</item>
<item>
    <title>Table Inheritance and the tableoid</title>
    <link>http://www.postgresonline.com/journal/archives/240-Table-Inheritance-and-the-tableoid.html</link>
            <category>8.2</category>
            <category>8.3</category>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>9.2</category>
            <category>beginner</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/240-Table-Inheritance-and-the-tableoid.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=240</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=240</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;If I could name a number one feature I love most about PostgreSQL, it&#039;s the table inheritance feature which we described in &lt;a href=&quot;http://www.postgresonline.com/journal/archives/59-How-to-Inherit,-Unherit-and-Merge-Inherit.html&quot; target=&quot;_blank&quot;&gt;How to Inherit and Uninherit&lt;/a&gt;. A lot of people use it for table partitioning using &lt;a href=&quot;http://www.postgresonline.com/journal/archives/27-Reading-PgAdmin-Graphical-Explain-Plans.html&quot; target=&quot;_blank&quot;&gt;CONSTRAINT EXCLUSION&lt;/a&gt;.  Aside from that, in combination with PostgreSQL schema search_path (customizable by user and/or database) it makes for a very flexible abstraction tool.  For example, for many of our web apps that service many departments where each department/client wants to keep a high level of autonomy, we have a schema set aside for each 
that inherits from a master template schema.  Each department site uses a different set of accounts with the primary schema being that of the department/client so that they are hitting their own  tables. &lt;/p&gt;
&lt;p&gt;Inheritance allows us to keep data separate,do roll-up reports if we need to, use the same application front-end, and yet allows us the ability to add new columns in just one place (the master template schema).  It is more flexible than other approaches because for example we may have a city organization that need to share tables, like for example a system loaded list of funding source shared across the agency.  We can set aside these shared tables in a separate schema visible to all or have some have their own copy they can change if they don&#039;t want to use the shared one.&lt;/p&gt;

&lt;p&gt;Every once in a while, we find ourselves needing to query the whole hierarchy and needing to know which table the results of the query are coming from. To help
solve that issue, we employ the use of the system column &lt;b&gt;tableoid&lt;/b&gt; which all user tables have. The tableoid is the the object id of a table.  PostgreSQL has many system columns that you have to explicitly select
and can&#039;t be accessed with a SELECT * with the tableoid being one of them.  These are: tableoid, cmax,cmin, xmin,xmax,ctid which are all described in &lt;a href=&quot;http://www.postgresql.org/docs/9.1/static/ddl-system-columns.html&quot; target=&quot;_blank&quot;&gt;System Columns&lt;/a&gt;.  The &lt;a href=&quot;http://www.postgresql.org/docs/9.1/static/ddl-inherit.html&quot; target=&quot;_blank&quot;&gt;PostgreSQL docs on inheritance&lt;/a&gt; have examples of using it, but we thought it worthwile to repeat the exercise since it&#039;s not that common knowledge and is unique enough feature of PostgreSQL that others coming from other relational databases, may miss the treat.  I&#039;ve often demonstrated
it to non-PostgreSQL users who use for example SQL Server or MySQL, and they literally fall out of their chair when I show the feature to them and its endless possibilities.&lt;/p&gt;   &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/240-Table-Inheritance-and-the-tableoid.html#extended&quot;&gt;Continue reading &quot;Table Inheritance and the tableoid&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 16 Jan 2012 05:52:54 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/240-guid.html</guid>
    
</item>
<item>
    <title>How big is my database and my other stuff</title>
    <link>http://www.postgresonline.com/journal/archives/233-How-big-is-my-database-and-my-other-stuff.html</link>
            <category>beginner</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/233-How-big-is-my-database-and-my-other-stuff.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=233</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=233</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;In this day and age of clouds and what not, it is still important to keep tabs on your database growth to ensure it doesn&#039;t
outgrow your disks or so that you can be prepared when it does.  A common question that is asked is how big your database is or all your databases combined.
Luckily PostgreSQL has had for a long time functions to help you answer this easily.  In this little article,
I&#039;ll demonstrate how to answer these questions and more with some PostgreSQL built-in functions&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/233-How-big-is-my-database-and-my-other-stuff.html#extended&quot;&gt;Continue reading &quot;How big is my database and my other stuff&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 21 Nov 2011 01:59:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/233-guid.html</guid>
    <category>postgresql</category>

</item>
<item>
    <title>What objects are in a PostgreSQL installed extension</title>
    <link>http://www.postgresonline.com/journal/archives/231-What-objects-are-in-a-PostgreSQL-installed-extension.html</link>
            <category>9.1</category>
            <category>intermediate</category>
            <category>postgis</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/231-What-objects-are-in-a-PostgreSQL-installed-extension.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=231</wfw:comment>

    <slash:comments>3</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=231</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;As mentioned in &lt;a href=&quot;http://www.postgresonline.com/journal/archives/227-Lessons-learned-Packaging-PostGIS-Extensions-Part-2.html&quot;&gt;Lessons Learned Packaging PostGIS extensions&lt;/a&gt;, I am working on PostGIS 2.0.0 extension packaging.  One of the things I wanted to know was what objects, types, functions etc were installed by my extension.  The new packaging system allows for cataloging this relatively easily, but I couldn&#039;t find a function or view for this  and didn&#039;t see one mentioned in the manual, so I created this query which seems to work pretty well as far as I can tell.  The basic idea being that any object that an extension depends on 
that is not an extension is part of the extension package.&lt;/p&gt;

&lt;code&gt;
&lt;pre&gt;&lt;span class=&quot;syntax0&quot;&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;SELECT&lt;/span&gt; c.relname &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; item_type, 
    &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;COALESCE&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;proc&lt;/span&gt;.proname,typ.typname, cd.relname, op.oprname, 
        &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;CAST(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; cs.typname &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;AS&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; ct.typname &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;, opcname, opfname&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; item_name,
    &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;COALESCE&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;proc&lt;/span&gt;.proisagg,false&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; is_agg, &lt;span class=&quot;syntax-FUNCTION&quot;&gt;oidvectortypes&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;proc&lt;/span&gt;.proargtypes&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; arg_types
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; pg_depend &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; d &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;INNER&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_extension &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; e
    &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; d.refobjid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; e.oid &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;INNER&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_class &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; c &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt;
        c.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.classid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_proc &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;proc&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;proc&lt;/span&gt;.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_type &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; typ &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; typ.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_class &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; cd &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; cd.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_operator &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; op &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; op.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_cast &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; ca &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; ca.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_type &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; cs &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; ca.castsource &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; cs.oid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_type &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; ct &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; ca.casttarget &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; ct.oid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_opclass &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; oc &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; oc.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_opfamily &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; ofa &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; ofa.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;WHERE&lt;/span&gt; d.deptype &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;and&lt;/span&gt; e.extname &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;postgis&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;BY&lt;/span&gt; item_type, item_name;
&lt;/span&gt;&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;The output looks like: &lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/231-What-objects-are-in-a-PostgreSQL-installed-extension.html#extended&quot;&gt;Continue reading &quot;What objects are in a PostgreSQL installed extension&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Thu, 03 Nov 2011 16:55:13 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/231-guid.html</guid>
    <category>extensions</category>
<category>postgis</category>

</item>
<item>
    <title>How to create an n-column table really fast</title>
    <link>http://www.postgresonline.com/journal/archives/230-How-to-create-an-n-column-table-really-fast.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>9.2</category>
            <category>beginner</category>
            <category>postgresql versions</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/230-How-to-create-an-n-column-table-really-fast.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=230</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=230</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;Ever have the need to create a holding table say spreadsheet data with say 100 columns. You need to create a table to hold this stuff.   Or perhaps you were feeling in a sadist mood and wanted to abuse your PostgreSQL database to see how many columns you can create in a table of a specific data type. 
Here is a quick script to do it:&lt;/p&gt;

&lt;code&gt;
&lt;pre&gt;&lt;span class=&quot;syntax0&quot;&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;8.4+&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;syntax&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;CREATE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;TABLE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;data_import(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;array_to_string&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-FUNCTION&quot;&gt;array_agg&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; i&lt;span class=&quot;syntax-OPERATOR&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;varchar(255)&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;, &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;generate_series&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;1&lt;/span&gt;,&lt;span class=&quot;syntax-DIGIT&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; i;

&lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;9.0+&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;syntax&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;(string_agg&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;was&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;introduced&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;9.0)&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;CREATE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;TABLE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;data_import(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;string_agg&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; i&lt;span class=&quot;syntax-OPERATOR&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;varchar(255)&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;, &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;generate_series&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;1&lt;/span&gt;,&lt;span class=&quot;syntax-DIGIT&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; i;
&lt;/span&gt;&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;Both variants will return output that looks like this: &lt;/p&gt;
&lt;pre&gt;&lt;span class=&quot;syntax0&quot;&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;TABLE&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;data_import&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;field1 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field2 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field3 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field4 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;
    ,field5 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field6 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field7 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;
    ,field8 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field9 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field10 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;;
&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Now if you want it to also execute because you are running it as part of an sql script, you could wrap it in an anonymous function.&lt;/p&gt;
&lt;code&gt;
&lt;pre&gt;&lt;span class=&quot;syntax0&quot;&gt; &lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;-wrap&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;an&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;anonymous&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;run&lt;/span&gt;
 &lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;requires&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;PostgreSQL&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;9.0+&lt;/span&gt;
DO language &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;plpgsql&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
$$
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;DECLARE&lt;/span&gt; var_sql &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;text&lt;/span&gt; :&lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;CREATE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;TABLE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;data_import(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
    &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;string_agg&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; i&lt;span class=&quot;syntax-OPERATOR&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;varchar(255)&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;, &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
    &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;generate_series&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;1&lt;/span&gt;,&lt;span class=&quot;syntax-DIGIT&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; i;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;BEGIN&lt;/span&gt;
    &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;EXECUTE&lt;/span&gt; var_sql;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;END&lt;/span&gt;;
$$ ;
&lt;/span&gt;&lt;/pre&gt;&lt;/code&gt;
 
    </content:encoded>

    <pubDate>Tue, 01 Nov 2011 22:31:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/230-guid.html</guid>
    <category>aggregates</category>
<category>array</category>
<category>array_agg</category>
<category>string_agg</category>

</item>
<item>
    <title>PostgreSQL Array: The ANY and Contains trick</title>
    <link>http://www.postgresonline.com/journal/archives/228-PostgreSQL-Array-The-ANY-and-Contains-trick.html</link>
            <category>intermediate</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/228-PostgreSQL-Array-The-ANY-and-Contains-trick.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=228</wfw:comment>

    <slash:comments>8</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=228</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;One of the main features I love about PostgreSQL is its array support.  This is a 
feature you won&#039;t find in most relational databases, and even databases that support some variant
of it, don&#039;t allow you to use it as easily.  It is one of the features that makes building
aggregate functions wicked easy in PostgreSQL with no messy compiling required.  
Aside from building aggregate functions, it has some other common day uses.  
In this article, I&#039;ll cover two common ways we use them which I will refer to as the &lt;b&gt;ANY&lt;/b&gt;
and &lt;b&gt;Contains&lt;/b&gt; tricks.&lt;/p&gt;

&lt;p&gt;I like to think of this approach as &lt;a href=&quot;http://blog.gigaspaces.com/2010/07/15/yesql-an-overview-of-the-various-query-semantics-in-the-post-only-sql-world/&quot; target=&quot;_blank&quot;&gt;YeSQL programming style&lt;/a&gt;: how SQL can be augmented by more complex data types and index retrieval mechanisms.
 Arrays and many other data types (spatial types, keyvalue (hstore), ltree etc) are far from relational structures, yet we can query them easily with SQL and can even relate them.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/228-PostgreSQL-Array-The-ANY-and-Contains-trick.html#extended&quot;&gt;Continue reading &quot;PostgreSQL Array: The ANY and Contains trick&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Thu, 27 Oct 2011 01:09:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/228-guid.html</guid>
    <category>aggregates</category>
<category>all</category>
<category>array</category>
<category>string_agg</category>
<category>yesql</category>

</item>
<item>
    <title>Bulk Revoke of Permissions for Specific Group/User role</title>
    <link>http://www.postgresonline.com/journal/archives/221-Bulk-Revoke-of-Permissions-for-Specific-GroupUser-role.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>intermediate</category>
            <category>mysql</category>
            <category>q&amp;a</category>
            <category>sql server</category>
    
    <comments>http://www.postgresonline.com/journal/archives/221-Bulk-Revoke-of-Permissions-for-Specific-GroupUser-role.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=221</wfw:comment>

    <slash:comments>3</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=221</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;div style=&#039;background-color:yellow&#039;&gt;&lt;p&gt;&lt;b&gt;UPDATE&lt;/b&gt; Turns out there is a simpler way of getting rid of roles that have explicit permissions to objects as Tom Lane pointed out in the comments.
&lt;pre&gt;&lt;code&gt;DROP OWNED BY some_role;&lt;/code&gt;&lt;/pre&gt;
&lt;/p&gt;
&lt;p&gt;Will drop the permissions to objects a user has rights to even if they don&#039;t own the objects.  Of course this needs to be applied with caution since it will drop tables
and other things you don&#039;t want necessarily dropped.  So it is best to first run a:
&lt;br /&gt;
&lt;code&gt;REASSIGN OWNED BY some_role TO new_role;&lt;/code&gt;
And then run the DROP OWNED BY.  &lt;br /&gt;
The &lt;a href=&quot;http://www.postgresql.org/docs/9.1/static/sql-reassign-owned.html&quot; target=&quot;_blank&quot;&gt;REASSIGN OWNED BY&lt;/a&gt; which is what we did originally is not sufficient since it doesn&#039;t drop the permissions or reassign
them as we assumed it would. This is noted in the docs.&lt;br /&gt;
And then you will be allowed to 
&lt;code&gt;DROP ROLE some_role&lt;/code&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;One of the things that is still tricky in PostgreSQL is permission management. Even though 9.0 brought us default privileges and the like, these permissions aren&#039;t
retroactive so still a pain to deal with if you already have objects defined in your database.&lt;/p&gt;

&lt;p&gt;One of the annoyances we come across with is deleting roles.  Lets say you have a role and it has explicit permissions to an object.
PostgreSQL won&#039;t allow you to delete this role if it owns objects or has explicit permissions to objects.  In order to delete it seems you have 
to go in and clear out all those permissions.  To help with that -- we wrote a quickie script that will generate a script to revoke all permissions on objects
for a specific role.  It looks like this:&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/221-Bulk-Revoke-of-Permissions-for-Specific-GroupUser-role.html#extended&quot;&gt;Continue reading &quot;Bulk Revoke of Permissions for Specific Group/User role&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 26 Sep 2011 00:11:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/221-guid.html</guid>
    <category>postgresql 8.4</category>
<category>regex</category>
<category>regular expressions</category>

</item>

</channel>
</rss>