Thread: get table schema in psql?

get table schema in psql?

From
Michael Teter
Date:
how can I get the schema of a table in psql?

in oracle I would do "desc tablename".  I remember sql
server and ingres having a similar facility.

right now the only way I seem to be able to get the
information is by using pgaccess.

I realize the definition of the table is probably
spread across the various pg_ system tables, but I'm
thinking there must be some easier way to get the
info.

in particular, I'm after the list of columns, their
data types and lengths, null/non-null, default values,
and table indices.

thanks,
michael

__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/


Re: get table schema in psql?

From
Patrik Kudo
Date:
Hi!

I think what you're looking for is

\d

and

\d name_of_table

You might also want to try

\?

for a list of all psql commands

Regards,
Patrik Kudo

ech`echo xiun|tr nu oc|sed 'sx\([sx]\)\([xoi]\)xo un\2\1 is xg'`ol
Känns det oklart? Fråga på!

On Fri, 15 Sep 2000, Michael Teter wrote:

> how can I get the schema of a table in psql?
> 
> in oracle I would do "desc tablename".  I remember sql
> server and ingres having a similar facility.
> 
> right now the only way I seem to be able to get the
> information is by using pgaccess.
> 
> I realize the definition of the table is probably
> spread across the various pg_ system tables, but I'm
> thinking there must be some easier way to get the
> info.
> 
> in particular, I'm after the list of columns, their
> data types and lengths, null/non-null, default values,
> and table indices.
> 
> thanks,
> michael
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Mail - Free email you can access from anywhere!
> http://mail.yahoo.com/
> 



Re: get table schema in psql?

From
Michael Teter
Date:
doh!

thanks so much.  somehow I thought \h and \? were the
same, and I've only been doing \h :)

no wonder I couldn't find it.

michael

--- Patrik Kudo <kudo@partitur.se> wrote:
> Hi!
> 
> I think what you're looking for is
> 
> \d
> 
> and
> 
> \d name_of_table
> 
> You might also want to try
> 
> \?
> 
> for a list of all psql commands
> 
> Regards,
> Patrik Kudo
> 
> ech`echo xiun|tr nu oc|sed 'sx\([sx]\)\([xoi]\)xo
> un\2\1 is xg'`ol
> K�nns det oklart? Fr�ga p�!
> 
> On Fri, 15 Sep 2000, Michael Teter wrote:
> 
> > how can I get the schema of a table in psql?
> > 
> > in oracle I would do "desc tablename".  I remember
> sql
> > server and ingres having a similar facility.
> > 
> > right now the only way I seem to be able to get
> the
> > information is by using pgaccess.
> > 
> > I realize the definition of the table is probably
> > spread across the various pg_ system tables, but
> I'm
> > thinking there must be some easier way to get the
> > info.
> > 
> > in particular, I'm after the list of columns,
> their
> > data types and lengths, null/non-null, default
> values,
> > and table indices.
> > 
> > thanks,
> > michael
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Mail - Free email you can access from
> anywhere!
> > http://mail.yahoo.com/
> > 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/


Re: get table schema in psql?

From
"Rommel B. Abaya"
Date:
type \d [tablename] at the psql console



Michael Teter wrote:

> how can I get the schema of a table in psql?
>
> in oracle I would do "desc tablename".  I remember sql
> server and ingres having a similar facility.
>
> right now the only way I seem to be able to get the
> information is by using pgaccess.
>
> I realize the definition of the table is probably
> spread across the various pg_ system tables, but I'm
> thinking there must be some easier way to get the
> info.
>
> in particular, I'm after the list of columns, their
> data types and lengths, null/non-null, default values,
> and table indices.
>
> thanks,
> michael
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Mail - Free email you can access from anywhere!
> http://mail.yahoo.com/



Re: get table schema in psql?

From
Jie Liang
Date:
Hi, there,

You just need type

psql> \d tablename
use
\? to get help

Michael Teter wrote:

> how can I get the schema of a table in psql?
>
> in oracle I would do "desc tablename".  I remember sql
> server and ingres having a similar facility.
>
> right now the only way I seem to be able to get the
> information is by using pgaccess.
>
> I realize the definition of the table is probably
> spread across the various pg_ system tables, but I'm
> thinking there must be some easier way to get the
> info.
>
> in particular, I'm after the list of columns, their
> data types and lengths, null/non-null, default values,
> and table indices.
>
> thanks,
> michael
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Mail - Free email you can access from anywhere!
> http://mail.yahoo.com/

--
Jie LIANG

Internet Products Inc.

10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873

jliang@ipinc.com
www.ipinc.com





Re: get table schema in psql?

From
"Roderick A. Anderson"
Date:
On Fri, 15 Sep 2000, Rommel B. Abaya wrote:

> type \d [tablename] at the psql console

And if you like that try:

\d+ [tablename]

Of course it's much more impressive if you've created any COMMENTs.


Rod
--
Roderick A. Anderson
raanders@altoplanos.net               Altoplanos Information Systems, Inc.
Voice: 208.765.6149                            212 S. 11th Street, Suite 5
FAX: 208.664.5299                                  Coeur d'Alene, ID 83814