<?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>PostgreSQL DBA Script &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/category/postgresql-dba-script/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Mon, 21 Jan 2019 07:21:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>PostgreSQL: Script to convert User to Super User</title>
		<link>https://www.dbrnd.com/2019/03/postgresql-script-to-convert-user-to-super-user/</link>
					<comments>https://www.dbrnd.com/2019/03/postgresql-script-to-convert-user-to-super-user/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 25 Mar 2019 16:16:47 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[super user]]></category>
		<category><![CDATA[User Permission]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7322</guid>

					<description><![CDATA[In this post, I am sharing a script for transforming normal DB user to Super User in PostgreSQL. The Super User is the admin user and it has all kind of access to PostgreSQL Server. We can create multiple superusers in PostgreSQL. I need this kind of handy commands/scripts because when any new dba join [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F03%2Fpostgresql-script-to-convert-user-to-super-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20convert%20User%20to%20Super%20User" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F03%2Fpostgresql-script-to-convert-user-to-super-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20convert%20User%20to%20Super%20User" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F03%2Fpostgresql-script-to-convert-user-to-super-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20convert%20User%20to%20Super%20User" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F03%2Fpostgresql-script-to-convert-user-to-super-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20convert%20User%20to%20Super%20User" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F03%2Fpostgresql-script-to-convert-user-to-super-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20convert%20User%20to%20Super%20User" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F03%2Fpostgresql-script-to-convert-user-to-super-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20convert%20User%20to%20Super%20User" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F03%2Fpostgresql-script-to-convert-user-to-super-user%2F&#038;title=PostgreSQL%3A%20Script%20to%20convert%20User%20to%20Super%20User" data-a2a-url="https://www.dbrnd.com/2019/03/postgresql-script-to-convert-user-to-super-user/" data-a2a-title="PostgreSQL: Script to convert User to Super User"></a></p><p>In this post, I am sharing a script for transforming normal DB user to Super User in PostgreSQL. </p>
<p>The Super User is the admin user and it has all kind of access to PostgreSQL Server. We can create multiple superusers in PostgreSQL. </p>
<p>I need this kind of handy commands/scripts because when any new dba join the team, giving basic permission of database and later the same user requires superuser permission. </p>
<p><strong>Convert a user into Super User:</strong></p>
<pre class="crayon-plain-tag">ALTER USER user_name WITH SUPERUSER;</pre> </p>
<p><strong>Revoke Super User Permission:</strong></p>
<pre class="crayon-plain-tag">ALTER USER user_name WITH NOSUPERUSER;</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2019/03/postgresql-script-to-convert-user-to-super-user/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Bash Shell Script to execute psql command in UNIX / LINUX</title>
		<link>https://www.dbrnd.com/2019/03/postgresql-bash-shell-script-to-execute-psql-command-in-unix-linux/</link>
					<comments>https://www.dbrnd.com/2019/03/postgresql-bash-shell-script-to-execute-psql-command-in-unix-linux/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 04 Mar 2019 16:16:25 +0000</pubDate>
				<category><![CDATA[Bash Shell Script]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[Bash shell script]]></category>
		<category><![CDATA[chmod]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[psql]]></category>
		<category><![CDATA[vi editor]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4374</guid>

					<description><![CDATA[As per the en.wikibooks.org: Bash is a &#8220;Unix shell&#8221;: a command-line interface for interacting with the operating system. It has the ability to run an entire script of commands, known as a &#8220;Bash shell script&#8221;. I recently started to create UNIX / LINUX Bash Shell script for enhancing my PostgreSQL DBA Work. You can create [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F03%2Fpostgresql-bash-shell-script-to-execute-psql-command-in-unix-linux%2F&amp;linkname=PostgreSQL%3A%20Bash%20Shell%20Script%20to%20execute%20psql%20command%20in%20UNIX%20%2F%20LINUX" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F03%2Fpostgresql-bash-shell-script-to-execute-psql-command-in-unix-linux%2F&amp;linkname=PostgreSQL%3A%20Bash%20Shell%20Script%20to%20execute%20psql%20command%20in%20UNIX%20%2F%20LINUX" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F03%2Fpostgresql-bash-shell-script-to-execute-psql-command-in-unix-linux%2F&amp;linkname=PostgreSQL%3A%20Bash%20Shell%20Script%20to%20execute%20psql%20command%20in%20UNIX%20%2F%20LINUX" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F03%2Fpostgresql-bash-shell-script-to-execute-psql-command-in-unix-linux%2F&amp;linkname=PostgreSQL%3A%20Bash%20Shell%20Script%20to%20execute%20psql%20command%20in%20UNIX%20%2F%20LINUX" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F03%2Fpostgresql-bash-shell-script-to-execute-psql-command-in-unix-linux%2F&amp;linkname=PostgreSQL%3A%20Bash%20Shell%20Script%20to%20execute%20psql%20command%20in%20UNIX%20%2F%20LINUX" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F03%2Fpostgresql-bash-shell-script-to-execute-psql-command-in-unix-linux%2F&amp;linkname=PostgreSQL%3A%20Bash%20Shell%20Script%20to%20execute%20psql%20command%20in%20UNIX%20%2F%20LINUX" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F03%2Fpostgresql-bash-shell-script-to-execute-psql-command-in-unix-linux%2F&#038;title=PostgreSQL%3A%20Bash%20Shell%20Script%20to%20execute%20psql%20command%20in%20UNIX%20%2F%20LINUX" data-a2a-url="https://www.dbrnd.com/2019/03/postgresql-bash-shell-script-to-execute-psql-command-in-unix-linux/" data-a2a-title="PostgreSQL: Bash Shell Script to execute psql command in UNIX / LINUX"></a></p><p>As per the en.wikibooks.org:</p>
<blockquote><p>Bash is a &#8220;Unix shell&#8221;: a command-line interface for interacting with the operating system. It has the ability to run an entire script of commands, known as a &#8220;Bash shell script&#8221;.</p></blockquote>
<p>I recently started to create UNIX / LINUX Bash Shell script for enhancing my PostgreSQL DBA Work. You can create a Bash shell script and can connect PostgreSQL using psql. </p>
<p>In this post, I am sharing a sample bash shell script to execute psql commands. </p>
<p><strong>Open a new file in vi editor:</strong></p>
<pre class="crayon-plain-tag">[root@dbrnd anvesh]$ vi helloworld.bash</pre> </p>
<p><strong>Press [i] key to get an insert prompt:</strong></p>
<p><strong>Copy below sample Bash Shell Script and Paste into vi editor:</strong></p>
<pre class="crayon-plain-tag">#!/bin/bash

###################################################
# First Bash Shell script to execute psql command 
###################################################

#Set the value of variable
database="database_name"

#Execute few psql commands: 
#Note: you can also add -h hostname -U username in the below commands. 

psql -d $database -c "CREATE TABLE public.tbl_students(rno integer, name character varying)"
psql -d $database -c "INSERT INTO public.tbl_students VALUES (1,'Anvesh'),(2,'Neevan'),(3,'Roy'),(4,'Martin'),(5,'Jenny')"
psql -d $database -c "SELECT *FROM public.tbl_students"

#Assign table count to variable
TableCount=$(psql -d $database -t -c "select count(1) from public.tbl_students")

#Print the value of variable
echo "Total table records count....:"$TableCount</pre> </p>
<p><strong>Press [Esc] key to get a command prompt and execute below command:</strong><br />
To save and exit vi editor.</p>
<pre class="crayon-plain-tag">:wq</pre> </p>
<p><strong>Give permission to the file:</strong></p>
<pre class="crayon-plain-tag">[root@dbrnd anvesh]$ chmod +x helloworld.bash</pre> </p>
<p><strong>Execute this file:</strong></p>
<pre class="crayon-plain-tag">[root@dbrnd anvesh]$ ./helloworld.bash</pre> </p>
<p><strong>You can find below result:</strong></p>
<pre class="crayon-plain-tag">rno |  name
-----+--------
   1 | Anvesh
   5 | Jenny
   2 | Neevan
   3 | Roy
   4 | Martin
(5 rows)

Total table records count....: 5</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2019/03/postgresql-bash-shell-script-to-execute-psql-command-in-unix-linux/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Script to find all Objects of a Particular User</title>
		<link>https://www.dbrnd.com/2018/09/postgresql-script-to-find-all-objects-of-a-particular-user/</link>
					<comments>https://www.dbrnd.com/2018/09/postgresql-script-to-find-all-objects-of-a-particular-user/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 03 Sep 2018 16:16:58 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[Database Role]]></category>
		<category><![CDATA[database user]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[pg_class]]></category>
		<category><![CDATA[pg_roles]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7708</guid>

					<description><![CDATA[In this post, I am sharing a script for getting the list of objects of a particular User (Owner of the Object) in PostgreSQL. Generally, PostgreSQL DBAs are using this kind of script for auditing purpose and object tracking purpose. Using the below script, you can get the list object for a particular user: I [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F09%2Fpostgresql-script-to-find-all-objects-of-a-particular-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20all%20Objects%20of%20a%20Particular%20User" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F09%2Fpostgresql-script-to-find-all-objects-of-a-particular-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20all%20Objects%20of%20a%20Particular%20User" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F09%2Fpostgresql-script-to-find-all-objects-of-a-particular-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20all%20Objects%20of%20a%20Particular%20User" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F09%2Fpostgresql-script-to-find-all-objects-of-a-particular-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20all%20Objects%20of%20a%20Particular%20User" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F09%2Fpostgresql-script-to-find-all-objects-of-a-particular-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20all%20Objects%20of%20a%20Particular%20User" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F09%2Fpostgresql-script-to-find-all-objects-of-a-particular-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20all%20Objects%20of%20a%20Particular%20User" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F09%2Fpostgresql-script-to-find-all-objects-of-a-particular-user%2F&#038;title=PostgreSQL%3A%20Script%20to%20find%20all%20Objects%20of%20a%20Particular%20User" data-a2a-url="https://www.dbrnd.com/2018/09/postgresql-script-to-find-all-objects-of-a-particular-user/" data-a2a-title="PostgreSQL: Script to find all Objects of a Particular User"></a></p><p>In this post, I am sharing a script for getting the list of objects of a particular User (Owner of the Object) in PostgreSQL.<br />
Generally, PostgreSQL DBAs are using this kind of script for auditing purpose and object tracking purpose. </p>
<p>Using the below script, you can get the list object for a particular user:</p>
<p>I used a &#8216;postgres&#8217; default user in WHERE condition, which you can edit as per your user.</p>
<pre class="crayon-plain-tag">select 
    nsp.nspname as SchemaName
    ,cls.relname as ObjectName 
    ,rol.rolname as ObjectOwner
    ,case cls.relkind
        when 'r' then 'TABLE'
        when 'm' then 'MATERIALIZED_VIEW'
        when 'i' then 'INDEX'
        when 'S' then 'SEQUENCE'
        when 'v' then 'VIEW'
        when 'c' then 'TYPE'
        else cls.relkind::text
    end as ObjectType
from pg_class cls
join pg_roles rol 
	on rol.oid = cls.relowner
join pg_namespace nsp 
	on nsp.oid = cls.relnamespace
where nsp.nspname not in ('information_schema', 'pg_catalog')
    and nsp.nspname not like 'pg_toast%'
    and rol.rolname = 'postgres'  
order by nsp.nspname, cls.relname</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2018/09/postgresql-script-to-find-all-objects-of-a-particular-user/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: How to get the list of all Schemas of a database in PSQL?</title>
		<link>https://www.dbrnd.com/2018/08/postgresql-how-to-get-the-list-of-all-schemas-of-a-database-in-psql/</link>
					<comments>https://www.dbrnd.com/2018/08/postgresql-how-to-get-the-list-of-all-schemas-of-a-database-in-psql/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 27 Aug 2018 16:16:27 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Get schemas]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[psql]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7705</guid>

					<description><![CDATA[In this post, I am sharing a command of PSQL for getting the list of Schemas of a database in PostgreSQL. PSQL is a handy tool for PostgreSQL DBAs and they are always preferring to use a command line tool. This article is for PostgreSQL beginner who is looking for the list of Schemas in [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-schemas-of-a-database-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20Schemas%20of%20a%20database%20in%20PSQL%3F" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-schemas-of-a-database-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20Schemas%20of%20a%20database%20in%20PSQL%3F" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-schemas-of-a-database-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20Schemas%20of%20a%20database%20in%20PSQL%3F" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-schemas-of-a-database-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20Schemas%20of%20a%20database%20in%20PSQL%3F" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-schemas-of-a-database-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20Schemas%20of%20a%20database%20in%20PSQL%3F" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-schemas-of-a-database-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20Schemas%20of%20a%20database%20in%20PSQL%3F" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-schemas-of-a-database-in-psql%2F&#038;title=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20Schemas%20of%20a%20database%20in%20PSQL%3F" data-a2a-url="https://www.dbrnd.com/2018/08/postgresql-how-to-get-the-list-of-all-schemas-of-a-database-in-psql/" data-a2a-title="PostgreSQL: How to get the list of all Schemas of a database in PSQL?"></a></p><p>In this post, I am sharing a command of PSQL for getting the list of Schemas of a database in PostgreSQL.</p>
<p>PSQL is a handy tool for PostgreSQL DBAs and they are always preferring to use a command line tool. </p>
<p>This article is for PostgreSQL beginner who is looking for the list of Schemas in PostgreSQL.</p>
<p><strong>How to connect the database in PSQL?</strong></p>
<pre class="crayon-plain-tag">-psql&gt;\connect database_name</pre> </p>
<p><strong>Get the list of schemas:</strong></p>
<pre class="crayon-plain-tag">-psql&gt; \dn</pre> </p>
<p><strong>Get the list of databases:</strong></p>
<pre class="crayon-plain-tag">-psql&gt; \list 
or 
-psql&gt; \l</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2018/08/postgresql-how-to-get-the-list-of-all-schemas-of-a-database-in-psql/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: How to get the list of all privileges of a database in PSQL?</title>
		<link>https://www.dbrnd.com/2018/08/postgresql-how-to-get-the-list-of-all-privileges-of-a-database-in-psql/</link>
					<comments>https://www.dbrnd.com/2018/08/postgresql-how-to-get-the-list-of-all-privileges-of-a-database-in-psql/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 20 Aug 2018 16:16:26 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[get databases]]></category>
		<category><![CDATA[get privileges]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[psql]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7703</guid>

					<description><![CDATA[In this post, I am sharing a command of PSQL for getting the list of privileges of a database in PostgreSQL. PSQL is a handy tool for PostgreSQL DBAs and they are always preferring to use a command line tool. This article is for PostgreSQL beginner who is looking for the list of privileges in [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-privileges-of-a-database-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20privileges%20of%20a%20database%20in%20PSQL%3F" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-privileges-of-a-database-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20privileges%20of%20a%20database%20in%20PSQL%3F" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-privileges-of-a-database-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20privileges%20of%20a%20database%20in%20PSQL%3F" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-privileges-of-a-database-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20privileges%20of%20a%20database%20in%20PSQL%3F" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-privileges-of-a-database-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20privileges%20of%20a%20database%20in%20PSQL%3F" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-privileges-of-a-database-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20privileges%20of%20a%20database%20in%20PSQL%3F" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-privileges-of-a-database-in-psql%2F&#038;title=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20privileges%20of%20a%20database%20in%20PSQL%3F" data-a2a-url="https://www.dbrnd.com/2018/08/postgresql-how-to-get-the-list-of-all-privileges-of-a-database-in-psql/" data-a2a-title="PostgreSQL: How to get the list of all privileges of a database in PSQL?"></a></p><p>In this post, I am sharing a command of PSQL for getting the list of privileges of a database in PostgreSQL.</p>
<p>PSQL is a handy tool for PostgreSQL DBAs and they are always preferring to use a command line tool. </p>
<p>This article is for PostgreSQL beginner who is looking for the list of privileges in PostgreSQL.</p>
<p><strong>How to connect the database in PSQL?</strong></p>
<pre class="crayon-plain-tag">-psql&gt;\connect database_name</pre> </p>
<p><strong>Get the list of databases:</strong></p>
<pre class="crayon-plain-tag">-psql&gt; \list 
or 
-psql&gt; \l</pre> </p>
<p><strong>Get the list of privileges:</strong></p>
<pre class="crayon-plain-tag">-psql&gt; \du</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2018/08/postgresql-how-to-get-the-list-of-all-privileges-of-a-database-in-psql/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: How to get the list of all tables and all databases in PSQL?</title>
		<link>https://www.dbrnd.com/2018/08/postgresql-how-to-get-the-list-of-all-tables-and-all-databases-in-psql/</link>
					<comments>https://www.dbrnd.com/2018/08/postgresql-how-to-get-the-list-of-all-tables-and-all-databases-in-psql/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 13 Aug 2018 16:16:20 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[get databases]]></category>
		<category><![CDATA[get tables]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[psql]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7700</guid>

					<description><![CDATA[In this post, I am sharing two commands of PSQL for getting the list of tables and databases in PostgreSQL. PSQL is a handy tool for PostgreSQL DBAs and they are always preferring to use a command line tool. This article is for PostgreSQL beginner who is looking for the list of tables and databases [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-tables-and-all-databases-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20tables%20and%20all%20databases%20in%20PSQL%3F" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-tables-and-all-databases-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20tables%20and%20all%20databases%20in%20PSQL%3F" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-tables-and-all-databases-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20tables%20and%20all%20databases%20in%20PSQL%3F" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-tables-and-all-databases-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20tables%20and%20all%20databases%20in%20PSQL%3F" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-tables-and-all-databases-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20tables%20and%20all%20databases%20in%20PSQL%3F" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-tables-and-all-databases-in-psql%2F&amp;linkname=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20tables%20and%20all%20databases%20in%20PSQL%3F" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F08%2Fpostgresql-how-to-get-the-list-of-all-tables-and-all-databases-in-psql%2F&#038;title=PostgreSQL%3A%20How%20to%20get%20the%20list%20of%20all%20tables%20and%20all%20databases%20in%20PSQL%3F" data-a2a-url="https://www.dbrnd.com/2018/08/postgresql-how-to-get-the-list-of-all-tables-and-all-databases-in-psql/" data-a2a-title="PostgreSQL: How to get the list of all tables and all databases in PSQL?"></a></p><p>In this post, I am sharing two commands of PSQL for getting the list of tables and databases in PostgreSQL.</p>
<p>PSQL is a handy tool for PostgreSQL DBAs and they are always preferring to use a command line tool. </p>
<p>This article is for PostgreSQL beginner who is looking for the list of tables and databases in PostgreSQL.</p>
<p><strong>Get the list of databases:</strong></p>
<pre class="crayon-plain-tag">-psql&gt; \list 
or 
-psql&gt; \l</pre> </p>
<p><strong>Get the list of tables:</strong><br />
You can&#8217;t get the list of all tables of all databases, but you can get the list of all tables of a particular database.<br />
First, you need to connect the database and then execute below command.</p>
<pre class="crayon-plain-tag">-psql&gt; \dt</pre> </p>
<p><strong>How to connect the database in PSQL?</strong></p>
<pre class="crayon-plain-tag">-psql&gt;\connect database_name</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2018/08/postgresql-how-to-get-the-list-of-all-tables-and-all-databases-in-psql/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Script to check the status of Shared Buffer (Use pg_buffercache)</title>
		<link>https://www.dbrnd.com/2018/04/postgresql-script-to-check-the-status-of-shared-buffer-use-pg_buffercache/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 09 Apr 2018 18:38:34 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[Buffer Cache]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Fast table access]]></category>
		<category><![CDATA[pg_buffercache]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Buffer]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[shared buffer]]></category>
		<category><![CDATA[Table in memory]]></category>
		<category><![CDATA[Table Performance]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7358</guid>

					<description><![CDATA[<div><img width="442" height="293" src="https://www.dbrnd.com/wp-content/uploads/2017/12/SQLMemory.jpg" class="attachment-post-image size-post-image wp-post-image" alt="SQL Memory" decoding="async" fetchpriority="high" /></div>In the previous post, I loaded table into the buffer cache of PostgreSQL (Using pg_prewarm). PostgreSQL: Load table into Buffer Cache, Increase the Speed of Accessing data In this post, I am sharing a script for checking the status of Shared buffer area of PostgreSQL. Using pg_buffercache, we can check this. I took the script [&#8230;]]]></description>
										<content:encoded><![CDATA[<div><img width="442" height="293" src="https://www.dbrnd.com/wp-content/uploads/2017/12/SQLMemory.jpg" class="attachment-post-image size-post-image wp-post-image" alt="SQL Memory" decoding="async" loading="lazy" /></div><p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-script-to-check-the-status-of-shared-buffer-use-pg_buffercache%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20Shared%20Buffer%20%28Use%20pg_buffercache%29" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-script-to-check-the-status-of-shared-buffer-use-pg_buffercache%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20Shared%20Buffer%20%28Use%20pg_buffercache%29" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-script-to-check-the-status-of-shared-buffer-use-pg_buffercache%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20Shared%20Buffer%20%28Use%20pg_buffercache%29" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-script-to-check-the-status-of-shared-buffer-use-pg_buffercache%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20Shared%20Buffer%20%28Use%20pg_buffercache%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-script-to-check-the-status-of-shared-buffer-use-pg_buffercache%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20Shared%20Buffer%20%28Use%20pg_buffercache%29" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-script-to-check-the-status-of-shared-buffer-use-pg_buffercache%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20Shared%20Buffer%20%28Use%20pg_buffercache%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-script-to-check-the-status-of-shared-buffer-use-pg_buffercache%2F&#038;title=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20Shared%20Buffer%20%28Use%20pg_buffercache%29" data-a2a-url="https://www.dbrnd.com/2018/04/postgresql-script-to-check-the-status-of-shared-buffer-use-pg_buffercache/" data-a2a-title="PostgreSQL: Script to check the status of Shared Buffer (Use pg_buffercache)"></a></p><p>In the previous post, I loaded table into the buffer cache of PostgreSQL (Using pg_prewarm).</p>
<blockquote class="wp-embedded-content" data-secret="eOfHAi2Qwf"><p><a href="https://www.dbrnd.com/2018/04/postgresql-load-table-into-buffer-cache-increase-the-speed-of-accessing-data-pg_prewarm/">PostgreSQL: Load table into Buffer Cache, Increase the Speed of Accessing data</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2018/04/postgresql-load-table-into-buffer-cache-increase-the-speed-of-accessing-data-pg_prewarm/embed/#?secret=eOfHAi2Qwf" data-secret="eOfHAi2Qwf" width="600" height="338" title="&#8220;PostgreSQL: Load table into Buffer Cache, Increase the Speed of Accessing data&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>In this post, I am sharing a script for checking the status of Shared buffer area of PostgreSQL.<br />
Using pg_buffercache, we can check this. I took the script from the this <a href="https://www.postgresql.org/docs/9.1/static/pgbuffercache.html" target="_blank" rel="noopener">official</a>.</p>
<p><strong>Please check the below script and output:</strong></p>
<p><strong>Create pg_buffercache module:</strong></p><pre class="crayon-plain-tag">CREATE EXTENSION pg_buffercache;</pre><p>
<strong>Script to check the status of Shared Buffer:</strong></p><pre class="crayon-plain-tag">SELECT 
    c.relname, 
    count(*) AS buffers
FROM pg_buffercache b 
INNER JOIN pg_class c
   ON b.relfilenode = pg_relation_filenode(c.oid) 
    	AND b.reldatabase IN (0, (SELECT oid FROM pg_database
WHERE datname = current_database()))
GROUP BY c.relname
ORDER BY 2 DESC;</pre><p>
<img decoding="async" class="alignnone size-full wp-image-7364" src="https://www.dbrnd.com/wp-content/uploads/2018/04/PostgreSQL-Shared-Buffer.png" alt="PostgreSQL Shared Buffer" width="403" height="141" /></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PostgreSQL: Script to check the status of AutoVacuum for all Tables</title>
		<link>https://www.dbrnd.com/2018/03/postgresql-script-to-check-the-status-of-autovacuum-for-all-tables/</link>
					<comments>https://www.dbrnd.com/2018/03/postgresql-script-to-check-the-status-of-autovacuum-for-all-tables/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 30 Mar 2018 16:16:01 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL DBA Script]]></category>
		<category><![CDATA[ANALYZE]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[AUTO VACUUM]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[VACUUM]]></category>
		<category><![CDATA[VACUUM FULL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7290</guid>

					<description><![CDATA[In this post, I am sharing a script for checking the status of AutoVacuum for all the PostgreSQL Tables. If you don&#8217;t know about the MVCC architecture, you must visit the below article. Because of MVCC, we have to work on dead tuples which are generated by transactions in PostgreSQL. What is Multi Version Concurrency [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fpostgresql-script-to-check-the-status-of-autovacuum-for-all-tables%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20AutoVacuum%20for%20all%20Tables" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fpostgresql-script-to-check-the-status-of-autovacuum-for-all-tables%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20AutoVacuum%20for%20all%20Tables" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fpostgresql-script-to-check-the-status-of-autovacuum-for-all-tables%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20AutoVacuum%20for%20all%20Tables" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fpostgresql-script-to-check-the-status-of-autovacuum-for-all-tables%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20AutoVacuum%20for%20all%20Tables" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fpostgresql-script-to-check-the-status-of-autovacuum-for-all-tables%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20AutoVacuum%20for%20all%20Tables" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fpostgresql-script-to-check-the-status-of-autovacuum-for-all-tables%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20AutoVacuum%20for%20all%20Tables" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F03%2Fpostgresql-script-to-check-the-status-of-autovacuum-for-all-tables%2F&#038;title=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20AutoVacuum%20for%20all%20Tables" data-a2a-url="https://www.dbrnd.com/2018/03/postgresql-script-to-check-the-status-of-autovacuum-for-all-tables/" data-a2a-title="PostgreSQL: Script to check the status of AutoVacuum for all Tables"></a></p><p>In this post, I am sharing a script for checking the status of AutoVacuum for all the PostgreSQL Tables. </p>
<p>If you don&#8217;t know about the MVCC architecture, you must visit the below article. Because of MVCC, we have to work on dead tuples which are generated by transactions in PostgreSQL. </p>
<blockquote class="wp-embedded-content" data-secret="JhjxG59FPW"><p><a href="https://www.dbrnd.com/2015/05/what-is-mvcc-multi-version-concurrency-control/">What is Multi Version Concurrency Control (MVCC)</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/05/what-is-mvcc-multi-version-concurrency-control/embed/#?secret=JhjxG59FPW" data-secret="JhjxG59FPW" width="600" height="338" title="&#8220;What is Multi Version Concurrency Control (MVCC)&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>You can configure auto-vacuum on tables, but periodically you should check the status of it. Use below script for checking the status of Autovacuum. </p>
<blockquote class="wp-embedded-content" data-secret="HyZBhFsEqV"><p><a href="https://www.dbrnd.com/2015/11/postgresql-short-note-on-vacuum-vacuum-full-and-analyze/">PostgreSQL: Short note on VACUUM, VACUUM FULL and ANALYZE</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/11/postgresql-short-note-on-vacuum-vacuum-full-and-analyze/embed/#?secret=HyZBhFsEqV" data-secret="HyZBhFsEqV" width="600" height="338" title="&#8220;PostgreSQL: Short note on VACUUM, VACUUM FULL and ANALYZE&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote class="wp-embedded-content" data-secret="gCeWbfwdsz"><p><a href="https://www.dbrnd.com/2016/08/postgresql-force-autovacuum-for-running-aggressive-improve-performance-of-autovacuum-frequent-run/">PostgreSQL: Force Autovacuum for running Aggressive</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/08/postgresql-force-autovacuum-for-running-aggressive-improve-performance-of-autovacuum-frequent-run/embed/#?secret=gCeWbfwdsz" data-secret="gCeWbfwdsz" width="600" height="338" title="&#8220;PostgreSQL: Force Autovacuum for running Aggressive&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<pre class="crayon-plain-tag">SELECT 
    schemaname
    ,relname
    ,n_live_tup
    ,n_dead_tup
    ,last_autovacuum
FROM pg_stat_all_tables
ORDER BY n_dead_tup
    /(n_live_tup
      * current_setting('autovacuum_vacuum_scale_factor')::float8
      + current_setting('autovacuum_vacuum_threshold')::float8)
     DESC</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2018/03/postgresql-script-to-check-the-status-of-autovacuum-for-all-tables/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Find a list of active Temp tables with Size and User information</title>
		<link>https://www.dbrnd.com/2017/06/postgresql-find-a-list-of-active-temp-tables-with-size-and-user-information-idle-connection/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 13 Jun 2017 16:16:32 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[Temp Table]]></category>
		<category><![CDATA[Temp Table Size]]></category>
		<category><![CDATA[Temp Tables]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5404</guid>

					<description><![CDATA[In this post, I am sharing a script to find a list of Temp tables with their size and user information in PostgreSQL. We all aware of the temp tables and many times developers are creating temp table for their ad-hoc testing purpose. But unfortunately sometimes, they forget to drop unused temp tables, and temp [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fpostgresql-find-a-list-of-active-temp-tables-with-size-and-user-information-idle-connection%2F&amp;linkname=PostgreSQL%3A%20Find%20a%20list%20of%20active%20Temp%20tables%20with%20Size%20and%20User%20information" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fpostgresql-find-a-list-of-active-temp-tables-with-size-and-user-information-idle-connection%2F&amp;linkname=PostgreSQL%3A%20Find%20a%20list%20of%20active%20Temp%20tables%20with%20Size%20and%20User%20information" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fpostgresql-find-a-list-of-active-temp-tables-with-size-and-user-information-idle-connection%2F&amp;linkname=PostgreSQL%3A%20Find%20a%20list%20of%20active%20Temp%20tables%20with%20Size%20and%20User%20information" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fpostgresql-find-a-list-of-active-temp-tables-with-size-and-user-information-idle-connection%2F&amp;linkname=PostgreSQL%3A%20Find%20a%20list%20of%20active%20Temp%20tables%20with%20Size%20and%20User%20information" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fpostgresql-find-a-list-of-active-temp-tables-with-size-and-user-information-idle-connection%2F&amp;linkname=PostgreSQL%3A%20Find%20a%20list%20of%20active%20Temp%20tables%20with%20Size%20and%20User%20information" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fpostgresql-find-a-list-of-active-temp-tables-with-size-and-user-information-idle-connection%2F&amp;linkname=PostgreSQL%3A%20Find%20a%20list%20of%20active%20Temp%20tables%20with%20Size%20and%20User%20information" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fpostgresql-find-a-list-of-active-temp-tables-with-size-and-user-information-idle-connection%2F&#038;title=PostgreSQL%3A%20Find%20a%20list%20of%20active%20Temp%20tables%20with%20Size%20and%20User%20information" data-a2a-url="https://www.dbrnd.com/2017/06/postgresql-find-a-list-of-active-temp-tables-with-size-and-user-information-idle-connection/" data-a2a-title="PostgreSQL: Find a list of active Temp tables with Size and User information"></a></p><p>In this post, I am sharing a script to find a list of Temp tables with their size and user information in PostgreSQL. </p>
<blockquote><p>We all aware of the temp tables and many times developers are creating temp table for their ad-hoc testing purpose.<br />
But unfortunately sometimes, they forget to drop unused temp tables, and temp tables keep active in those idle connections. It also requires unnecessary utilization of disk space.</p></blockquote>
<p>So now, DBAs are responsible for identifying unused temp tables and then inform to developers so that they can drop their unused temp tables.</p>
<pre class="crayon-plain-tag">SELECT
	n.nspname as SchemaName
	,c.relname as RelationName
	,CASE c.relkind
	WHEN 'r' THEN 'table'
	WHEN 'v' THEN 'view'
	WHEN 'i' THEN 'index'
	WHEN 'S' THEN 'sequence'
	WHEN 's' THEN 'special'
	END as RelationType
	,pg_catalog.pg_get_userbyid(c.relowner) as RelationOwner               
	,pg_size_pretty(pg_relation_size(n.nspname ||'.'|| c.relname)) as RelationSize
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n               
                ON n.oid = c.relnamespace
WHERE  c.relkind IN ('r','s') 
AND  (n.nspname !~ '^pg_toast' and nspname like 'pg_temp%')
ORDER BY pg_relation_size(n.nspname ||'.'|| c.relname) DESC</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PostgreSQL: Script to find the count of objects for each Database Schema</title>
		<link>https://www.dbrnd.com/2017/06/postgresql-script-to-find-the-count-of-objects-for-each-database-schema/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 07 Jun 2017 16:16:56 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[object count]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5371</guid>

					<description><![CDATA[In this post, I am sharing a script to find the total count of objects for each database schemas of PostgreSQL. If you Postgres DBA and want to do accounting on a number of total objects per schemas, you can use this script. Using this script, you can find different types of objects count like [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fpostgresql-script-to-find-the-count-of-objects-for-each-database-schema%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20count%20of%20objects%20for%20each%20Database%20Schema" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fpostgresql-script-to-find-the-count-of-objects-for-each-database-schema%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20count%20of%20objects%20for%20each%20Database%20Schema" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fpostgresql-script-to-find-the-count-of-objects-for-each-database-schema%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20count%20of%20objects%20for%20each%20Database%20Schema" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fpostgresql-script-to-find-the-count-of-objects-for-each-database-schema%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20count%20of%20objects%20for%20each%20Database%20Schema" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fpostgresql-script-to-find-the-count-of-objects-for-each-database-schema%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20count%20of%20objects%20for%20each%20Database%20Schema" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fpostgresql-script-to-find-the-count-of-objects-for-each-database-schema%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20count%20of%20objects%20for%20each%20Database%20Schema" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fpostgresql-script-to-find-the-count-of-objects-for-each-database-schema%2F&#038;title=PostgreSQL%3A%20Script%20to%20find%20the%20count%20of%20objects%20for%20each%20Database%20Schema" data-a2a-url="https://www.dbrnd.com/2017/06/postgresql-script-to-find-the-count-of-objects-for-each-database-schema/" data-a2a-title="PostgreSQL: Script to find the count of objects for each Database Schema"></a></p><p>In this post, I am sharing a script to find the total count of objects for each database schemas of PostgreSQL.<br />
If you Postgres DBA and want to do accounting on a number of total objects per schemas, you can use this script.</p>
<p>Using this script, you can find different types of objects count like table, view, index, sequence.</p>
<pre class="crayon-plain-tag">SELECT
	n.nspname as schema_name
	,CASE c.relkind
	   WHEN 'r' THEN 'table'
	   WHEN 'v' THEN 'view'
	   WHEN 'i' THEN 'index'
	   WHEN 'S' THEN 'sequence'
	   WHEN 's' THEN 'special'
	END as object_type
	,count(1) as object_count
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','i','S','s')
GROUP BY  n.nspname,
	CASE c.relkind
	   WHEN 'r' THEN 'table'
	   WHEN 'v' THEN 'view'
	   WHEN 'i' THEN 'index'
	   WHEN 'S' THEN 'sequence'
	   WHEN 's' THEN 'special'
	END
ORDER BY n.nspname,
	CASE c.relkind
	   WHEN 'r' THEN 'table'
	   WHEN 'v' THEN 'view'
	   WHEN 'i' THEN 'index'
	   WHEN 'S' THEN 'sequence'
	   WHEN 's' THEN 'special'
	END;</pre> </p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
