<?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>ads' corner - SQL</title>
    <link>http://andreas.scherbaum.la/blog/</link>
    <description>a place to store my stuff</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5.3 - http://www.s9y.org/</generator>
    <pubDate>Wed, 08 Oct 2008 21:34:51 GMT</pubDate>

    <image>
        <url>http://andreas.scherbaum.la/blog/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: ads' corner - SQL - a place to store my stuff</title>
        <link>http://andreas.scherbaum.la/blog/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>role ... cannot be dropped because some objects depend on it</title>
    <link>http://andreas.scherbaum.la/blog/archives/439-role-...-cannot-be-dropped-because-some-objects-depend-on-it.html</link>
            <category>Code Snippets</category>
            <category>PostgreSQL News</category>
            <category>SQL</category>
    
    <comments>http://andreas.scherbaum.la/blog/archives/439-role-...-cannot-be-dropped-because-some-objects-depend-on-it.html#comments</comments>
    <wfw:comment>http://andreas.scherbaum.la/blog/wfwcomment.php?cid=439</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://andreas.scherbaum.la/blog/rss.php?version=2.0&amp;type=comments&amp;cid=439</wfw:commentRss>
    

    <author>nospam@example.com (Andreas 'ads' Scherbaum)</author>
    <content:encoded>
    &lt;div class=&quot;serendipity_authorpic&quot;&gt;&lt;img src=&quot;http://andreas.scherbaum.la/blog/templates/default/img/Andreas__ads__Scherbaum.jpg&quot; alt=&quot;Author&quot; title=&quot;Andreas &#039;ads&#039; Scherbaum&quot; /&gt;&lt;br /&gt;&lt;span&gt;Andreas &#039;ads&#039; Scherbaum&lt;/span&gt;&lt;/div&gt;&lt;p class=&quot;break&quot;&gt;
I want to &lt;a target=&quot;_blank&quot; href=&quot;http://andreas.scherbaum.la/blog/exit.php?url_id=6070&amp;amp;entry_id=439&quot; title=&quot;http://www.postgresql.org/docs/8.3/interactive/sql-droprole.html&quot;  onmouseover=&quot;window.status=&#039;http://www.postgresql.org/docs/8.3/interactive/sql-droprole.html&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;drop a ROLE&lt;/a&gt; (previously USER/GROUPs) which is still referenced by object(s) in my database. But &lt;a title=&quot;The PostgreSQL Project&quot; target=&quot;_blank&quot; href=&quot;http://andreas.scherbaum.la/blog/exit.php?url_id=6071&amp;amp;entry_id=439&quot;  onmouseover=&quot;window.status=&#039;http://www.postgresql.org/&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;PostgreSQL&lt;/a&gt; has objections:&lt;br /&gt;&lt;br /&gt;&lt;address&gt;ERROR:  role &amp;quot;xyz&amp;quot; cannot be dropped because some objects depend on it&lt;/address&gt;&lt;address&gt;DETAIL:  access to schema public&lt;/address&gt;&lt;br /&gt;&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://andreas.scherbaum.la/blog/archives/439-role-...-cannot-be-dropped-because-some-objects-depend-on-it.html#extended&quot;&gt;Continue reading &quot;role ... cannot be dropped because some objects depend on it&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Wed, 10 Sep 2008 20:11:07 +0200</pubDate>
    <guid isPermaLink="false">http://andreas.scherbaum.la/blog/archives/439-guid.html</guid>
    <category>Code snippets</category>
<category>PostgreSQL</category>

</item>
<item>
    <title>create language if not exist</title>
    <link>http://andreas.scherbaum.la/blog/archives/346-create-language-if-not-exist.html</link>
            <category>PL/pgSQL</category>
            <category>PostgreSQL</category>
            <category>PostgreSQL News</category>
            <category>SQL</category>
    
    <comments>http://andreas.scherbaum.la/blog/archives/346-create-language-if-not-exist.html#comments</comments>
    <wfw:comment>http://andreas.scherbaum.la/blog/wfwcomment.php?cid=346</wfw:comment>

    <slash:comments>7</slash:comments>
    <wfw:commentRss>http://andreas.scherbaum.la/blog/rss.php?version=2.0&amp;type=comments&amp;cid=346</wfw:commentRss>
    

    <author>nospam@example.com (Andreas 'ads' Scherbaum)</author>
    <content:encoded>
    &lt;div class=&quot;serendipity_authorpic&quot;&gt;&lt;img src=&quot;http://andreas.scherbaum.la/blog/templates/default/img/Andreas__ads__Scherbaum.jpg&quot; alt=&quot;Author&quot; title=&quot;Andreas &#039;ads&#039; Scherbaum&quot; /&gt;&lt;br /&gt;&lt;span&gt;Andreas &#039;ads&#039; Scherbaum&lt;/span&gt;&lt;/div&gt;&lt;p class=&quot;break&quot;&gt;
&lt;font face=&quot;arial,helvetica,sans-serif&quot;&gt;&lt;p&gt;In a customer project i have to setup a database from a Makefile. Part of my problem: on windows the installer may or may not install &amp;quot;plpgsql&amp;quot; into template1 so in consequence this language would be activated in every new database. But that&#039;s not predictable. This problem can appear on different Linux/Unix distributions too.&lt;/p&gt;&lt;p&gt;In contrary to some other opinions in #postgresql i dislike filtering error messages and i prefer clean solutions.&lt;/p&gt;&lt;/font&gt;&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://andreas.scherbaum.la/blog/archives/346-create-language-if-not-exist.html#extended&quot;&gt;Continue reading &quot;create language if not exist&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Thu, 27 Mar 2008 08:33:14 +0100</pubDate>
    <guid isPermaLink="false">http://andreas.scherbaum.la/blog/archives/346-guid.html</guid>
    <category>PostgreSQL</category>
<category>SQL</category>
<category>pl/pgSQL</category>

</item>
<item>
    <title>Understanding SQL</title>
    <link>http://andreas.scherbaum.la/blog/archives/304-Understanding-SQL.html</link>
            <category>Externes</category>
            <category>SQL</category>
            <category>Software</category>
            <category>other DBs</category>
    
    <comments>http://andreas.scherbaum.la/blog/archives/304-Understanding-SQL.html#comments</comments>
    <wfw:comment>http://andreas.scherbaum.la/blog/wfwcomment.php?cid=304</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://andreas.scherbaum.la/blog/rss.php?version=2.0&amp;type=comments&amp;cid=304</wfw:commentRss>
    

    <author>nospam@example.com (Andreas 'ads' Scherbaum)</author>
    <content:encoded>
    &lt;div class=&quot;serendipity_authorpic&quot;&gt;&lt;img src=&quot;http://andreas.scherbaum.la/blog/templates/default/img/Andreas__ads__Scherbaum.jpg&quot; alt=&quot;Author&quot; title=&quot;Andreas &#039;ads&#039; Scherbaum&quot; /&gt;&lt;br /&gt;&lt;span&gt;Andreas &#039;ads&#039; Scherbaum&lt;/span&gt;&lt;/div&gt;&lt;p class=&quot;break&quot;&gt;
&lt;font face=&quot;arial,helvetica,sans-serif&quot;&gt;&lt;p&gt;Just have to port a &lt;a href=&quot;http://andreas.scherbaum.la/blog/exit.php?url_id=5164&amp;amp;entry_id=304&quot; title=&quot;http://www.phpkit.de/&quot;  onmouseover=&quot;window.status=&#039;http://www.phpkit.de/&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; target=&quot;_blank&quot;&gt;phpkit&lt;/a&gt; database to something else. It seems, the phpkit ppl did not really understand what SQL is for.&lt;/p&gt;&lt;p&gt;The &#039;phpkit_config&#039; table in this case contains 255(!) columns and a lot of this columns seems to be for extensions.&lt;/p&gt;&lt;p&gt;This is a very good example where you should use &lt;a href=&quot;http://andreas.scherbaum.la/blog/exit.php?url_id=5165&amp;amp;entry_id=304&quot; title=&quot;http://en.wikipedia.org/wiki/Database_normalization&quot;  onmouseover=&quot;window.status=&#039;http://en.wikipedia.org/wiki/Database_normalization&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; target=&quot;_blank&quot;&gt;normalization&lt;/a&gt;: you don&#039;t add more and more columns to one table but you have a key/value table and for new entries you add a new key with a value. No need to change the table at all.&lt;/p&gt;&lt;/font&gt;&lt;/p&gt; 
    </content:encoded>

    <pubDate>Sun, 13 Jan 2008 15:29:56 +0100</pubDate>
    <guid isPermaLink="false">http://andreas.scherbaum.la/blog/archives/304-guid.html</guid>
    <category>SQL</category>

</item>
<item>
    <title>table size, database size</title>
    <link>http://andreas.scherbaum.la/blog/archives/282-table-size,-database-size.html</link>
            <category>Code Snippets</category>
            <category>PostgreSQL News</category>
            <category>SQL</category>
    
    <comments>http://andreas.scherbaum.la/blog/archives/282-table-size,-database-size.html#comments</comments>
    <wfw:comment>http://andreas.scherbaum.la/blog/wfwcomment.php?cid=282</wfw:comment>

    <slash:comments>15</slash:comments>
    <wfw:commentRss>http://andreas.scherbaum.la/blog/rss.php?version=2.0&amp;type=comments&amp;cid=282</wfw:commentRss>
    

    <author>nospam@example.com (Andreas 'ads' Scherbaum)</author>
    <content:encoded>
    &lt;div class=&quot;serendipity_authorpic&quot;&gt;&lt;img src=&quot;http://andreas.scherbaum.la/blog/templates/default/img/Andreas__ads__Scherbaum.jpg&quot; alt=&quot;Author&quot; title=&quot;Andreas &#039;ads&#039; Scherbaum&quot; /&gt;&lt;br /&gt;&lt;span&gt;Andreas &#039;ads&#039; Scherbaum&lt;/span&gt;&lt;/div&gt;&lt;p class=&quot;break&quot;&gt;
&lt;font face=&quot;arial,helvetica,sans-serif&quot;&gt;&lt;/p&gt;&lt;p class=&quot;break&quot;&gt;I have seen this question &lt;a href=&quot;http://andreas.scherbaum.la/blog/exit.php?url=aHR0cDovL3d3dy5wb3N0Z3Jlc3FsZm9ydW1zLmNvbS9mb3J1bXMvdmlld3RvcGljLnBocD9mPTQyJnQ9NDE3&amp;amp;entry_id=282&quot;  onmouseover=&quot;window.status=&#039;http://www.postgresqlforums.com/forums/viewtopic.php?f=42&amp;amp;t=417&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; target=&quot;_blank&quot; title=&quot;Posting on postgresqlforums.com&quot;&gt;more than once&lt;/a&gt; in the past: &amp;quot;How much storage space do i need for my table?&amp;quot;&lt;br /&gt;PostgreSQL can give you &lt;a href=&quot;http://andreas.scherbaum.la/blog/exit.php?url_id=5065&amp;amp;entry_id=282&quot;  onmouseover=&quot;window.status=&#039;http://www.postgresql.org/docs/current/static/functions-admin.html#FUNCTIONS-ADMIN-DBSIZE&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; target=&quot;_blank&quot; title=&quot;PostgreSQL documentation for the current version&quot;&gt;this information&lt;/a&gt;.&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font face=&quot;arial,helvetica,sans-serif&quot;&gt;The storage space (in bytes) for one specific table:&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;ads=# select pg_relation_size(&#039;size_test&#039;);&lt;br /&gt;pg_relation_size&lt;br /&gt;------------------&lt;br /&gt;          5668864&lt;br /&gt;          (1 row)&lt;br /&gt;&lt;br /&gt;&lt;font face=&quot;arial,helvetica,sans-serif&quot;&gt;Same query, but with the result in a human-readable format:&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;ads=# select pg_size_pretty(pg_relation_size(&#039;size_test&#039;));&lt;br /&gt;pg_size_pretty&lt;br /&gt;----------------&lt;br /&gt; 5536 kB(1 row)&lt;br /&gt;&lt;br /&gt;&lt;font face=&quot;arial,helvetica,sans-serif&quot;&gt;Remember that this is only the size of the table, not included an index or additional stuff.&lt;br /&gt;The size including any index can be found out with:&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;ads=# select pg_size_pretty(pg_total_relation_size(&#039;size_test&#039;));&lt;br /&gt; pg_size_pretty&lt;br /&gt;----------------&lt;br /&gt; 7656 kB&lt;br /&gt;(1 row)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;font face=&quot;arial,helvetica,sans-serif&quot;&gt;The size of a complete database:&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;ads=# select pg_size_pretty(pg_database_size(&#039;ads&#039;));&lt;br /&gt; pg_size_pretty&lt;br /&gt;----------------&lt;br /&gt; 11 MB&lt;br /&gt;(1 row)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;font face=&quot;arial,helvetica,sans-serif&quot;&gt;You can even find out, how much space a specific value needs:&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;ads=# select pg_column_size(5::smallint);&lt;br /&gt; pg_column_size&lt;br /&gt;----------------&lt;br /&gt;              2&lt;br /&gt;(1 row)&lt;br /&gt;&lt;br /&gt;ads=# select pg_column_size(5::int);&lt;br /&gt; pg_column_size&lt;br /&gt;----------------&lt;br /&gt;              4&lt;br /&gt;(1 row)&lt;br /&gt;&lt;br /&gt;ads=# select pg_column_size(5::bigint);&lt;br /&gt; pg_column_size&lt;br /&gt;----------------&lt;br /&gt;              8&lt;br /&gt;(1 row)&lt;br /&gt;&lt;br /&gt;ads=# select pg_column_size(&#039;This is a string&#039;::varchar);&lt;br /&gt; pg_column_size&lt;br /&gt;----------------&lt;br /&gt;             20&lt;br /&gt;(1 row)&lt;br /&gt;&lt;br /&gt;ads=# select length(&#039;This is a string&#039;::varchar);&lt;br /&gt; length&lt;br /&gt;--------&lt;br /&gt;     16&lt;br /&gt;(1 row)&lt;br /&gt;&lt;br /&gt;&lt;font face=&quot;arial,helvetica,sans-serif&quot;&gt;The 4 byte difference between the column size and the string length is the storage overhead needed for &lt;a href=&quot;http://andreas.scherbaum.la/blog/exit.php?url_id=5066&amp;amp;entry_id=282&quot;  onmouseover=&quot;window.status=&#039;http://www.postgresql.org/docs/current/static/datatype-character.html&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; target=&quot;_blank&quot; title=&quot;Documentation for character types in PostgreSQL&quot;&gt;varchar&lt;/a&gt; columns.&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;font face=&quot;arial,helvetica,sans-serif&quot;&gt;The size for a tablespace can be found out with pg_tablespace_size(), but i don&#039;t have a machine with configured tablespace at hand to show an example.&lt;/font&gt;&lt;/p&gt; 
    </content:encoded>

    <pubDate>Tue, 04 Dec 2007 11:07:00 +0100</pubDate>
    <guid isPermaLink="false">http://andreas.scherbaum.la/blog/archives/282-guid.html</guid>
    <category>Code snippets</category>
<category>PostgreSQL</category>
<category>SQL</category>

</item>

</channel>
</rss>
