Thread: doubt about the database

doubt about the database

From
"maridu h.s.n.v.prasad"
Date:
subscribe
end

hai sir
 i am using the postgresql 7.2 my doubt is
what is the command of to see the list of databases
 i create a database named "jntuoes"
 database created it's displayed
but i want to know the command
so please give me the replay

thak you sir



_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

Re: doubt about the database

From
"Scott Marlowe"
Date:
On Sun, 2004-09-26 at 01:49, maridu h.s.n.v.prasad wrote:
> subscribe
> end
>
> hai sir
>  i am using the postgresql 7.2 my doubt is
> what is the command of to see the list of databases
>  i create a database named "jntuoes"
>  database created it's displayed
> but i want to know the command
> so please give me the replay

in psql, you use \l

smarlowe=> \l
        List of databases
   Name    |  Owner   | Encoding
-----------+----------+-----------
 blog      | smarlowe | SQL_ASCII
 postgres  | postgres | SQL_ASCII
 smarlowe  | smarlowe | SQL_ASCII
 template0 | postgres | SQL_ASCII
 template1 | postgres | SQL_ASCII
(5 rows)

If you want to execute a command to see it from SQL (i.e. an application
etc...) you can find the queries psql uses by starting it with the -E
switch, like so:

[smarlowe@localhost smarlowe]$ psql -E
Welcome to psql 7.4.5, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

smarlowe=> \l
********* QUERY **********
SELECT d.datname as "Name",
       u.usename as "Owner",
       pg_catalog.pg_encoding_to_char(d.encoding) as "Encoding"
FROM pg_catalog.pg_database d
  LEFT JOIN pg_catalog.pg_user u ON d.datdba = u.usesysid
ORDER BY 1;
**************************

        List of databases
   Name    |  Owner   | Encoding
-----------+----------+-----------
 blog      | smarlowe | SQL_ASCII
 postgres  | postgres | SQL_ASCII
 smarlowe  | smarlowe | SQL_ASCII
 template0 | postgres | SQL_ASCII
 template1 | postgres | SQL_ASCII
(5 rows)

Hope that helps.