Thread: describe command

describe command

From
Merrill Oveson
Date:
Postgresql:

Oracle has a command "describe"

e.g.

"describe cars" or  "desc cars"

where cars is the name of the table.

this command  describes the attributes of a table.

e.g.

Name        Null        Type                Constraint
------------------------------
VIN                           char(20)        Primary key
Make        Not Null   varchar(20)
Model                        varchar(20)

Does Postgresql have anything similar?
I could find the command "describe" anywhere in the documentation.

Merrill


Re: describe command

From
Ed Loehr
Date:
Merrill Oveson wrote:
>
> Oracle has a command "describe"
>
> Does Postgresql have anything similar?

See \d under

    http://www.postgresql.org/docs/postgres/app-psql.htm

Re: describe command

From
Charles Tassell
Date:
You can do this with \d tablename in psql.  Or, the SQL commands to
generate the same thing are:

QUERY: SELECT a.attnum, a.attname, t.typname, a.attlen, a.atttypmod,
a.attnotnull, a.atthasdef FROM pg_class c, pg_attribute a, pg_type t WHERE
c.relname = 'tablename'    and a.attnum > 0     and a.attrelid =
c.oid     and a.atttypid = t.oid   ORDER BY attnum

QUERY: SELECT viewname, definition FROM pg_views WHERE viewname like
'tablename'


At 06:05 PM 4/10/00, Merrill Oveson wrote:
>Postgresql:
>
>Oracle has a command "describe"
>
>e.g.
>
>"describe cars" or  "desc cars"
>
>where cars is the name of the table.
>
>this command  describes the attributes of a table.
>
>e.g.
>
>Name        Null        Type                Constraint
>------------------------------
>VIN                           char(20)        Primary key
>Make        Not Null   varchar(20)
>Model                        varchar(20)
>
>Does Postgresql have anything similar?
>I could find the command "describe" anywhere in the documentation.
>
>Merrill