"show databases" in psql way?
"show databases" in psql way?
am 01.11.2004 13:13:10 von erik.wasser
Hi list,
how can I list the databases in a postgresish way? I know about the '-l'
switch of 'psql' but is there a DBI/SQL-query way? I don't want to call
an external program only to list the databases. I've googled about this
problem but I only found the '-l'-way to this this.
Ideas? Solutions?
--
So long... Fuzz
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Re: "show databases" in psql way?
am 01.11.2004 13:23:54 von fbax
At 07:13 AM 11/1/04, Erik Wasser wrote:
>how can I list the databases in a postgresish way? I know about the '-l'
>switch of 'psql' but is there a DBI/SQL-query way? I don't want to call
>an external program only to list the databases. I've googled about this
>problem but I only found the '-l'-way to this this.
The -e switch of psql will display queries behind commands. So use this
option, the use 'l' as a command instead of a switch.
Frank
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
Re: "show databases" in psql way?
am 01.11.2004 13:26:56 von barwick
On Mon, 1 Nov 2004 13:13:10 +0100, Erik Wasser wrote:
> Hi list,
>
> how can I list the databases in a postgresish way? I know about the '-l'
> switch of 'psql' but is there a DBI/SQL-query way? I don't want to call
> an external program only to list the databases. I've googled about this
> problem but I only found the '-l'-way to this this.
>
> Ideas? Solutions?
Start psql with the -E switch, and it shows the SQL used to generate
the output from psql's slash commands.
Ian Barwick
barwick@gmail.com
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
Re: "show databases" in psql way?
am 01.11.2004 13:33:12 von erik.wasser
On Monday 01 November 2004 13:26, Ian Barwick wrote:
> Start psql with the -E switch, and it shows the SQL used to generate
> the output from psql's slash commands.
Thanks for the quick answer. I will remember this switch! B-)
--
So long... Fuzz
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
Re: "show databases" in psql way?
am 02.11.2004 04:40:53 von Greg
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> how can I list the databases in a postgresish way? I know
> about the '-l' switch of 'psql' but is there a DBI/SQL-query way?
Yes, the DBI way is to use the "data_sources" function. Works
just fine for Postgres:
my @dbs = DBI->data_sources('Pg');
- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200411012240
-----BEGIN PGP SIGNATURE-----
iD8DBQFBhwIHvJuQZxSWSsgRArd1AJ9hKXD+cSaM2L3RUXQdabuRofNFjwCf aHT0
+bRPuYhuED0mnlp1FRtvQQw=
=tsqe
-----END PGP SIGNATURE-----
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
Re: "show databases" in psql way?
am 02.11.2004 15:24:02 von lorid
\z will list the tables in the dbase
\d tablename will list the columns in the table
---------------------
Erik Wasser wrote:
>Hi list,
>
>how can I list the databases in a postgresish way? I know about the '-l'
>switch of 'psql' but is there a DBI/SQL-query way? I don't want to call
>an external program only to list the databases. I've googled about this
>problem but I only found the '-l'-way to this this.
>
>Ideas? Solutions?
>
>
>
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
Re: "show databases" in psql way?
am 02.11.2004 16:03:40 von Arash_Zaryoun
in command line: psql template1 pgsql -l
in PSQL:
foodb=3D#> select datname from pg_database;
- Arash
>>> Achilleus Mantzios 11/2/2004 10:21:06 AM=
>>>
O lorid ****** **** Nov 2, 2004 :
> \z will list the tables in the dbase
> \d tablename will list the columns in the table
>=20
or=20
foodb=3D# SELECT oid,* from pg_database ;
> ---------------------
> Erik Wasser wrote:
>=20
> >Hi list,
> >
> >how can I list the databases in a postgresish way? I know about the '-l'=
=20
> >switch of 'psql' but is there a DBI/SQL-query way? I don't want to call=
=20
> >an external program only to list the databases. I've googled about this=
=20
> >problem but I only found the '-l'-way to this this.
> >
> >Ideas? Solutions?
> >
> >
> >
>=20
>=20
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>=20
> http://www.postgresql.org/docs/faqs/FAQ.html=20
>=20
--=20
-Achilleus
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
Re: "show databases" in psql way?
am 02.11.2004 16:21:06 von achill
O lorid Ýãñáøå óôéò Nov 2, 2004 :
> \z will list the tables in the dbase
> \d tablename will list the columns in the table
>
or
foodb=# SELECT oid,* from pg_database ;
> ---------------------
> Erik Wasser wrote:
>
> >Hi list,
> >
> >how can I list the databases in a postgresish way? I know about the '-l'
> >switch of 'psql' but is there a DBI/SQL-query way? I don't want to call
> >an external program only to list the databases. I've googled about this
> >problem but I only found the '-l'-way to this this.
> >
> >Ideas? Solutions?
> >
> >
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>
--
-Achilleus
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
Re: "show databases" in psql way?
am 03.11.2004 04:46:23 von Greg
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
To be pedantic about it, use:
SELECT pg_catalog.quote_ident(datname) AS database
FROM pg_catalog.pg_database ORDER BY 1;
or if using version 8 or higher:
SELECT pg_catalog.quote_ident(datname) AS database,
pg_catalog.quote_ident(spcname) AS tablespace
FROM pg_catalog.pg_database
JOIN pg_catalog.pg_tablespace t ON (dattablespace=t.oid)
ORDER BY 1;
- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200411022120
-----BEGIN PGP SIGNATURE-----
iD8DBQFBiFTSvJuQZxSWSsgRApflAJ0RiVndbc6u//cXX/S7uM8K91lWbgCf YVbC
MsRNWlP446AcvHm0UaGgEVo=
=S8Ft
-----END PGP SIGNATURE-----
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://archives.postgresql.org