Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

to get the list of schemas in postgresql db

by ansh batra (Friar)
on Nov 22, 2011 at 05:45 UTC ( #939369=perlquestion: print w/ replies, xml ) Need Help??
ansh batra has asked for the wisdom of the Perl Monks concerning the following question:

hi monks
how can i get the list of all the schemas present in a postgres database?

Comment on to get the list of schemas in postgresql db
Re: to get the list of schemas in postgresql db
by zwon (Monsignor) on Nov 22, 2011 at 06:29 UTC

    The same way you will do it without perl, select * from pg_namespace I guess.

      ur query is correct zwon but for that i need to connect to a database first
      cant we supply the database name in the query itself?? thanks

        Easy answer :) : No


        Enjoy, Have FUN! H.Merijn
Re: to get the list of schemas in postgresql db
by erix (Vicar) on Dec 04, 2011 at 11:27 UTC

    But TMTOWTDI (SQL standard compliant):

    select schema_name from information_schema.schemata where schema_name <> 'information_schema' -- exclude 'system' schemata and schema_name !~ E'^pg_' -- exclude more 'system' (pg +-specific)

    In psql there is \dn to retrieve schema names. If PGPASSFILE is set (and possibly more PG* environment variables like PGDATABASE), you can just talk to the database from the commandline:

    echo '\dn' | psql

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://939369]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2015-04-27 02:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who makes your decisions?







    Results (493 votes), past polls