<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Tech-Recipes - Latest Comments in List the databases on a PostgreSQL/PgSQL server</title><link>http://tech-recipes.disqus.com/</link><description>Cookbook of Tech Tutorials</description><atom:link href="https://tech-recipes.disqus.com/list_the_databases_on_a_postgresqlpgsql_server_postgresql_pgsql_tech_recipes/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 14 Oct 2010 11:59:51 -0000</lastBuildDate><item><title>Re: List the databases on a PostgreSQL/PgSQL server</title><link>http://www.tech-recipes.com/rx/280/list-the-databases-on-a-postgresqlpgsql-server/#comment-86934422</link><description>&lt;p&gt;I assume you normally want to see a list of all databases NOT including the default PostgreSQL databases. For that you can execute the following SQL query:&lt;br&gt;SELECT datname FROM pg_database WHERE datistemplate IS FALSE AND datallowconn IS TRUE AND datname!='postgres';&lt;/p&gt;&lt;p&gt;To use that from the command line (for scripts...e.g. a backup script) you might want to call it using 'psql':&lt;br&gt;psql --quiet --no-align --tuples-only --dbname=postgres --username=postgres --host=127.0.0.1 --port=5432 --command="SELECT datname FROM pg_database WHERE datistemplate IS FALSE AND datallowconn IS TRUE AND datname!='postgres';"&lt;/p&gt;&lt;p&gt;If you don't want to be asked by psql for the PostgreSQL password (because you run it in batch script), you need to set the following environment variable in your batch script:&lt;br&gt;SET PGPASSWORD=yoursecretpassword&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mars99</dc:creator><pubDate>Thu, 14 Oct 2010 11:59:51 -0000</pubDate></item><item><title>Re: List the databases on a PostgreSQL/PgSQL server</title><link>http://www.tech-recipes.com/rx/280/list-the-databases-on-a-postgresqlpgsql-server/#comment-47469696</link><description>&lt;p&gt;select d.datname as name from pg_catalog.pg_database d;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Rob</dc:creator><pubDate>Thu, 29 Apr 2010 14:31:28 -0000</pubDate></item><item><title>Re: List the databases on a PostgreSQL/PgSQL server</title><link>http://www.tech-recipes.com/rx/280/list-the-databases-on-a-postgresqlpgsql-server/#comment-39502519</link><description>&lt;p&gt;salamo alikom&lt;br&gt;can you provide it in sql query .&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">0xSIFE</dc:creator><pubDate>Sat, 13 Mar 2010 06:46:27 -0000</pubDate></item><item><title>Re: List the databases on a PostgreSQL/PgSQL server</title><link>http://www.tech-recipes.com/rx/280/list-the-databases-on-a-postgresqlpgsql-server/#comment-14350297</link><description>&lt;p&gt;worked like a charm&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">rogerdpack</dc:creator><pubDate>Thu, 06 Aug 2009 12:17:30 -0000</pubDate></item></channel></rss>