Thread: exploring data

exploring data

From
Willie Northway
Date:
Hello, I'm a mysql user who's trying to learn postgres. How would I
explore which databases or tables are available for use?

If I were using mysql, I would try something like this:

mysql> show databases;
mysql> use test;
mysql> show tables;

How would I accomplish something like this in postgres?

- Willie

----
Willie Northway - Software Developer http://www.willienorthway.com/
Diamond Bullet Design - http://www.diamondbullet.com


Re: exploring data

From
harrold@sage.che.pitt.edu
Date:

--
john

Sometime in June Willie Northway assaulted keyboard and produced...

|
|Hello, I'm a mysql user who's trying to learn postgres. How would I
|explore which databases or tables are available for use?
|
|If I were using mysql, I would try something like this:
|
|mysql> show databases;
|mysql> use test;


normally when postgres is started you tell it the database.

so it looks something like
psql dbname

then to show the tables
dbname=# \d
will list all the tables, sequences, etc in a "more" fashion

then to get info about a table just type

dbname=# \d table

this will give you a list of the columns and datatypes.

i dont know how to list the available databaes.

i hope this helps.

|mysql> show tables;
|
|How would I accomplish something like this in postgres?
|
|- Willie
|
|----
|Willie Northway - Software Developer http://www.willienorthway.com/
|Diamond Bullet Design - http://www.diamondbullet.com
|
|
|---------------------------(end of broadcast)---------------------------
|TIP 6: Have you searched our list archives?
|
|http://www.postgresql.org/search.mpl
|


RE: exploring data

From
"Williams, Travis L, NPONS"
Date:
type \? for a list of all the \ commands.. one of them will give you how to
list the DB's and another will show you how to list the tables.. I know it's
kinda different.. I come from a SQL7 world..

Travis

-----Original Message-----
From: Willie Northway [mailto:willn@diamondbullet.com]
Sent: Wednesday, June 27, 2001 1:18 PM
To: pgsql-novice@postgresql.org
Subject: [NOVICE] exploring data



Hello, I'm a mysql user who's trying to learn postgres. How would I
explore which databases or tables are available for use?

If I were using mysql, I would try something like this:

mysql> show databases;
mysql> use test;
mysql> show tables;

How would I accomplish something like this in postgres?

- Willie

----
Willie Northway - Software Developer http://www.willienorthway.com/
Diamond Bullet Design - http://www.diamondbullet.com


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl

Re: exploring data

From
Willie Northway
Date:
On Wed, 27 Jun 2001 harrold@sage.che.pitt.edu wrote:

> normally when postgres is started you tell it the database.

Is there a way to just start the postgres client, and switch databases
after seeing what is available? Or would I have to connect using a dummy
database, browse, then switch?

> then to show the tables
> dbname=# \d

this definitely helps, thanks.

> i dont know how to list the available databaes.

I started browsing the source code, and found \l (as in L) lists the
databases.

- Willie



Re: exploring data

From
Willie Northway
Date:
After some digging in the source code, namely this file:
"src/bin/psql/describe.c" -> I've found the "real" SQL commands
which the backslash commands use:

to list databases:
\list or \l or
SELECT datname FROM pg_database WHERE datname !~ '^template';

to list tables in the currently used database:
\d or
SELECT relname FROM pg_class WHERE relname!~ '^pg_';

- Willie

----
Willie Northway - Software Developer http://www.willienorthway.com/
Diamond Bullet Design - http://www.diamondbullet.com


Re: Re: exploring data

From
Nabil Sayegh
Date:
On 27 Jun 2001 17:25:55 -0400, Willie Northway wrote:
>
> After some digging in the source code, namely this file:
> "src/bin/psql/describe.c" -> I've found the "real" SQL commands
> which the backslash commands use:

Why didn't you use `psql -E` ;)

--
 Nabil Sayegh