Table description

Started by Livia Santosover 18 years ago5 messagesgeneral
Jump to latest
#1Livia Santos
liviasilvasantos@gmail.com

Hi.

Is there any command that describe a table, such as desc table_name as in
Oracle?

Thanks in advance.

--
Lívia Silva Santos

#2Richard Broersma Jr
rabroersma@yahoo.com
In reply to: Livia Santos (#1)
Re: Table description
--- Livia Santos <liviasilvasantos@gmail.com> wrote:

Is there any command that describe a table, such as desc table_name as in
Oracle?

from the psql user interface, you can use the following command:

\dt
to list all table in the currently set schema

\d [table_name]
the see the table attributes

\d+ [table_name]
to see additional table attributes

Regards,
Richard Broersma Jr.

#3Scott Marlowe
scott.marlowe@gmail.com
In reply to: Livia Santos (#1)
Re: Table description

On 8/20/07, Livia Santos <liviasilvasantos@gmail.com> wrote:

Hi.

Is there any command that describe a table, such as desc table_name as in
Oracle?

Yes and no. The psql client has a series of \ commands that can
describe pretty much anything in the db in a pretty print nature and a
minimum of typing. The \ commands are NOT implemented in the backend,
but in the psql client so you can't just hit the db with \d from a
libpq connection to get a list of all tables / views / sequences.

However, you can use psql -E to have psql show you al lthe queries
it's throwing at the backend to get that pretty output, and then you
can take what it's doing and either wrap it in a view for future use,
or run it directly.

#4Robert Gravsjö
robert@blogg.se
In reply to: Livia Santos (#1)
Re: Table description

Livia Santos wrote:

Hi.

Is there any command that describe a table, such as desc table_name as
in Oracle?

Not sure how desc table_name works in Oracle, but from psql you can use:
\dt table_name

Issue \? in psql for more information.

Regards,
roppert

Show quoted text

Thanks in advance.

--
Lívia Silva Santos

#5Livia Santos
liviasilvasantos@gmail.com
In reply to: Robert Gravsjö (#4)
Re: Table description

Thanks a lot, guys.

\d <table_name> is exactly what I needed!

On 8/20/07, Robert Gravsjö <robert@blogg.se> wrote:

Livia Santos wrote:

Hi.

Is there any command that describe a table, such as desc table_name as
in Oracle?

Not sure how desc table_name works in Oracle, but from psql you can use:
\dt table_name

Issue \? in psql for more information.

Regards,
roppert

Thanks in advance.

--
Lívia Silva Santos

--
Lívia Silva Santos
Unicamp/Ceset TI02