<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>kb.hurricane-ridge.com &#187; PostgreSQL</title>
	<atom:link href="http://kb.hurricane-ridge.com/category/dbms/postgresql/feed" rel="self" type="application/rss+xml" />
	<link>http://kb.hurricane-ridge.com</link>
	<description>My personal - but public - knowledge base</description>
	<lastBuildDate>Mon, 09 Jan 2012 14:49:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Bulk Changing PostgreSQL Permissions</title>
		<link>http://kb.hurricane-ridge.com/dbms/postgresql/bulk-changing-postgresql-permissions</link>
		<comments>http://kb.hurricane-ridge.com/dbms/postgresql/bulk-changing-postgresql-permissions#comments</comments>
		<pubDate>Mon, 25 Oct 2010 20:23:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[authorization]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://kb.hurricane-ridge.com/?p=996</guid>
		<description><![CDATA[In a comp.databases.postgresql.general thread from 2004, John Sidney-Woollett details how to change PostgreSQL permissions on tables, views, functions and sequences in bulk &#8211; go to the thread for background and further details. In case the thread should become unavailable, queries are replicated below: Tables Views Functions Sequences]]></description>
			<content:encoded><![CDATA[<p>In a <a href="http://groups.google.com/group/comp.databases.postgresql.general/browse_frm/thread/ff71d8a24f21e8af?hl=en&#038;lr&#038;ie=UTF-8&#038;c2coff=1&#038;rnum=2&#038;prev=/groups?q%3Dgrant%2Ball%2Bgroup:comp.databases.postgresql.*%26hl%3Den%26lr%3D%26ie%3DUTF-8%26group%3Dcomp.databases.postgresql.*%26c2coff%3D1%26selm%3D2698.192.168.0.64.1086352944.squirrel%2540mercury.wardbrook.com%26rnum%3D2">comp.databases.postgresql.general thread from 2004</a>, John Sidney-Woollett details how to change PostgreSQL permissions on tables, views, functions and sequences in bulk &#8211; go to <a href="http://groups.google.com/group/comp.databases.postgresql.general/browse_frm/thread/ff71d8a24f21e8af?hl=en&#038;lr&#038;ie=UTF-8&#038;c2coff=1&#038;rnum=2&#038;prev=/groups?q%3Dgrant%2Ball%2Bgroup:comp.databases.postgresql.*%26hl%3Den%26lr%3D%26ie%3DUTF-8%26group%3Dcomp.databases.postgresql.*%26c2coff%3D1%26selm%3D2698.192.168.0.64.1086352944.squirrel%2540mercury.wardbrook.com%26rnum%3D2">the thread</a> for background and further details.  In case the thread should become unavailable, queries are replicated below:</p>
<p><strong>Tables</strong></p>
<pre class="brush: sql; title: ; notranslate">
select 'grant all on '||schemaname||'.'||tablename||' to SOMEUSERNAME;'
from pg_tables
where schemaname in ('SOMESCHEMA1', 'SOMESCHEMA2')
order by schemaname, tablename;
</pre>
<p><strong>Views</strong></p>
<pre class="brush: sql; title: ; notranslate">
SELECT 'grant all on '||n.nspname||'.'||c.relname||' to SOMEUSERNAME;'
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname in ('SOMESCHEMA1', 'SOMESCHEMA2')
and c.relkind = 'v'
ORDER BY n.nspname, c.relname;
</pre>
<p><strong>Functions</strong></p>
<pre class="brush: sql; title: ; notranslate">
select 'grant all on function
'||n.nspname||'.'||p.proname||'('||oidvectortypes(p.proargtypes)||') to
SOMEUSERNAME;'
from pg_proc p, pg_namespace n
where n.oid = p.pronamespace
and n.nspname in ('SOMESCHEMA1', 'SOMESCHEMA2')
order by n.nspname, p.proname;
</pre>
<p><strong>Sequences</strong></p>
<pre class="brush: sql; title: ; notranslate">
select 'grant all on '||n.nspname||'.'||c.relname||' to MYUSERNAME;'
from pg_class c, pg_namespace n
where n.oid = c.relnamespace
and c.relkind IN ('S')
and n.nspname in ('SOMESCHEMA1', 'SOMESCHEMA2');
</pre>
]]></content:encoded>
			<wfw:commentRss>http://kb.hurricane-ridge.com/dbms/postgresql/bulk-changing-postgresql-permissions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PostgreSQL Query Monitoring</title>
		<link>http://kb.hurricane-ridge.com/dbms/postgresql/postgresql-query-monitoring</link>
		<comments>http://kb.hurricane-ridge.com/dbms/postgresql/postgresql-query-monitoring#comments</comments>
		<pubDate>Sun, 15 Feb 2009 16:01:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[postgresql.conf]]></category>
		<category><![CDATA[psql]]></category>

		<guid isPermaLink="false">http://kb.hurricane-ridge.com/?p=293</guid>
		<description><![CDATA[postgres=# select * from pg_stat_activity; datid &#124; datname &#124; procpid &#124; usesysid &#124; usename &#124; current_query &#124; query_start &#124; backend_start &#124; client_addr &#124; client_port -------+----------+---------+----------+----------+---------------+-------------------------------+-------------------------------+-------------+------------- 10793 &#124; postgres &#124; 3443 &#124; 10 &#124; postgres &#124; &#60;IDLE&#62; &#124; 2009-02-15 07:36:14.272725-08 &#124; 2009-02-15 07:36:14.272521-08 &#124; &#124; -1 (1 row) If you do not have stats_command_string set to [...]]]></description>
			<content:encoded><![CDATA[<pre>postgres=# select * from pg_stat_activity;
 datid | datname  | procpid | usesysid | usename  | current_query |          query_start          |         backend_start         | client_addr | client_port
-------+----------+---------+----------+----------+---------------+-------------------------------+-------------------------------+-------------+-------------
 10793 | postgres |    3443 |       10 | postgres | &lt;IDLE&gt;        | 2009-02-15 07:36:14.272725-08 | 2009-02-15 07:36:14.272521-08 |             |          -1
(1 row)</pre>
<p>If you do not have <code>stats_command_string</code> set to <code>on</code> in your <code>postgresql.conf</code>, you will see output similar to the following:</p>
<pre>postgres=#  select * from pg_stat_activity;
 datid | datname  | procpid | usesysid |    usename    |        current_query         | query_start |         backend_start         | client_addr | client_port
-------+----------+---------+----------+---------------+------------------------------+-------------+-------------------------------+-------------+-------------
 10793 | postgres |    2275 |       10 | postgres      | &lt;command string not enabled&gt; |             | 2009-02-15 07:50:40.940629-08 |             |          -1
 16712 | isx      |   11447 |    16956 | rails_app0174 | &lt;command string not enabled&gt; |             | 2009-01-07 11:52:52.683856-08 | 172.16.1.4  |       44881
 16712 | isx      |    6037 |    16956 | rails_app0174 | &lt;command string not enabled&gt; |             | 2008-12-30 17:15:17.110313-08 | 172.16.1.4  |       37302
(3 rows)</pre>
]]></content:encoded>
			<wfw:commentRss>http://kb.hurricane-ridge.com/dbms/postgresql/postgresql-query-monitoring/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

