Thread: DESC

DESC

From
Mike Castle
Date:
Not just a pgsql novice, but an SQL novice in general.

Is there an equivalent for the SQL command DESC for listing the columns
and their various types?  (I've played around with Oracle's sqlplus stuff
a very little bit and this is command existed there and from I've seen
so far, should be an ANSI standard.)

I looked through the email archives and didn't see anything.

Oh, dear.  I just went to check again, and off of the User's Lounge, the
General Information link (http://www.postgresql.org/gen-info.html) just
gave me a 404 error.  Someone reorganizing?

Anyway, I've pondered writing such a thing, and decided to look at how
pg_dump figures things out and quickly decided to ask first.

Thanks,
mrc
--
       Mike Castle       Life is like a clock:  You can work constantly
  dalgoda@ix.netcom.com  and be right all the time, or not work at all
www.netcom.com/~dalgoda/ and be right at least twice a day.  -- mrc
    We are all of us living in the shadow of Manhattan.  -- Watchmen

Re: DESC

From
Rynell Wesson
Date:
Start a psql session on the db you want and type \d <table name> and this
will describe the table for you.  You should also type \? for more options
under psql.

Thanks.

Rynell Wesson

On Tue, 21 Nov 2000, Mike Castle wrote:

>
> Not just a pgsql novice, but an SQL novice in general.
>
> Is there an equivalent for the SQL command DESC for listing the columns
> and their various types?  (I've played around with Oracle's sqlplus stuff
> a very little bit and this is command existed there and from I've seen
> so far, should be an ANSI standard.)
>
> I looked through the email archives and didn't see anything.
>
> Oh, dear.  I just went to check again, and off of the User's Lounge, the
> General Information link (http://www.postgresql.org/gen-info.html) just
> gave me a 404 error.  Someone reorganizing?
>
> Anyway, I've pondered writing such a thing, and decided to look at how
> pg_dump figures things out and quickly decided to ask first.
>
> Thanks,
> mrc
> --
>        Mike Castle       Life is like a clock:  You can work constantly
>   dalgoda@ix.netcom.com  and be right all the time, or not work at all
> www.netcom.com/~dalgoda/ and be right at least twice a day.  -- mrc
>     We are all of us living in the shadow of Manhattan.  -- Watchmen
>


Re: DESC

From
Paul M Foster
Date:
On Tue, Nov 21, 2000 at 12:58:44PM -0600, Mike Castle wrote:

>
> Not just a pgsql novice, but an SQL novice in general.
>
> Is there an equivalent for the SQL command DESC for listing the columns
> and their various types?  (I've played around with Oracle's sqlplus stuff
> a very little bit and this is command existed there and from I've seen
> so far, should be an ANSI standard.)
>

If I understand you correctly, the only thing I know of is available in
the psql front end. It is the \d command, as in:

\d mytable

Else I know of nothing. Unfortunately.

Paul

Re: DESC

From
"Albert REINER"
Date:
On Tue, Nov 21, 2000 at 08:01:27PM -0500, Paul M Foster wrote:
> On Tue, Nov 21, 2000 at 12:58:44PM -0600, Mike Castle wrote:
...
> > Is there an equivalent for the SQL command DESC for listing the columns
> > and their various types?  (I've played around with Oracle's sqlplus stuff
> > a very little bit and this is command existed there and from I've seen
> > so far, should be an ANSI standard.)
...
> If I understand you correctly, the only thing I know of is available in
> the psql front end. It is the \d command, as in:
>
> \d mytable

And if you start psql with option -E you will see the actual
SQL-queries used by \d.

A.

--

--------------------------------------------------------------------------
Albert Reiner                                   <areiner@tph.tuwien.ac.at>
Deutsch       *       English       *       Esperanto       *       Latine
--------------------------------------------------------------------------

Re: DESC

From
Mike Castle
Date:
On Wed, Nov 22, 2000 at 06:38:15PM +0100, Albert REINER wrote:
> And if you start psql with option -E you will see the actual
> SQL-queries used by \d.

That's nifty.  I've read through all of the pgsql documentation before
starting everything, but I think I'm suffering a bit from information
overload.  I knew this information was somewhere, I just couldn't remember
where.

So, thanks to all who pointed me to \d.

Ok then.  It looks to me like both "DESC" and "DESCRIBE" are SQL keywords.
DESC apparently is meant for descending, so I'm guessing that Oracle's
sqlplus usage of DESC is an extension.  Is that correct?

If so, is "DESCRIBE" the ANSI command that should do what \d does or does
it serve another purpose in ANSI?  (A pointer as to where to find this
explicitly would be nice; will eventually purchase the standard myself).

If DESCRIBE is supposed to do that, is there any reason that pgsql doesn't
do that outside of "\d works, so no one has bothered to implement it."

Thanks,
mrc
--
       Mike Castle       Life is like a clock:  You can work constantly
  dalgoda@ix.netcom.com  and be right all the time, or not work at all
www.netcom.com/~dalgoda/ and be right at least twice a day.  -- mrc
    We are all of us living in the shadow of Manhattan.  -- Watchmen

Re: DESC

From
"D. Duccini"
Date:
describe isn't really an SQL reserved AFAIK, its used in most "monitor"
applications, like sqlplus and pgsql

> On Wed, Nov 22, 2000 at 06:38:15PM +0100, Albert REINER wrote:
> > And if you start psql with option -E you will see the actual
> > SQL-queries used by \d.
>
> That's nifty.  I've read through all of the pgsql documentation before
> starting everything, but I think I'm suffering a bit from information
> overload.  I knew this information was somewhere, I just couldn't remember
> where.
>
> So, thanks to all who pointed me to \d.
>
> Ok then.  It looks to me like both "DESC" and "DESCRIBE" are SQL keywords.
> DESC apparently is meant for descending, so I'm guessing that Oracle's
> sqlplus usage of DESC is an extension.  Is that correct?
>
> If so, is "DESCRIBE" the ANSI command that should do what \d does or does
> it serve another purpose in ANSI?  (A pointer as to where to find this
> explicitly would be nice; will eventually purchase the standard myself).
>
> If DESCRIBE is supposed to do that, is there any reason that pgsql doesn't
> do that outside of "\d works, so no one has bothered to implement it."
>
> Thanks,
> mrc
> --
>        Mike Castle       Life is like a clock:  You can work constantly
>   dalgoda@ix.netcom.com  and be right all the time, or not work at all
> www.netcom.com/~dalgoda/ and be right at least twice a day.  -- mrc
>     We are all of us living in the shadow of Manhattan.  -- Watchmen
>


-----------------------------------------------------------------------------
david@backpack.com            BackPack Software, Inc.        www.backpack.com
+1 651.645.7550 voice       "Life is an Adventure.
+1 651.645.9798 fax            Don't forget your BackPack!"
-----------------------------------------------------------------------------


Re: DESC

From
Tom Lane
Date:
Mike Castle <dalgoda@ix.netcom.com> writes:
> If so, is "DESCRIBE" the ANSI command that should do what \d does or does
> it serve another purpose in ANSI?

The only use of DESCRIBE that I can find in the SQL92 spec is

         <describe statement> ::=
                <describe input statement>
              | <describe output statement>

         <describe input statement> ::=
              DESCRIBE INPUT <SQL statement name> <using descriptor>

         <describe output statement> ::=
              DESCRIBE [ OUTPUT ] <SQL statement name> <using descriptor>

         Obtain information about the <select list> columns or <dynamic
         parameter specification>s contained in a prepared statement.

which doesn't appear to overlap \d's functionality at all...

            regards, tom lane

Re: DESC

From
Mike Castle
Date:
On Wed, Nov 22, 2000 at 01:01:10PM -0600, D. Duccini wrote:
>
> describe isn't really an SQL reserved AFAIK, its used in most "monitor"
> applications, like sqlplus and pgsql

From http://www.postgresql.org/users-lounge/docs/v7.0/user/syntax.htm

   The following are either SQL92 or SQL3 reserved key words which are
   not key words in Postgres. These have no proscribed usage in Postgres
   at the time of writing (v7.0) but may become reserved key words in the
   future:

[deleted]
DATE DEALLOCATE DEC DESCRIBE DESCRIPTOR
[deleted]

That's why I was asking.  More curiosity than anything.

mrc
--
       Mike Castle       Life is like a clock:  You can work constantly
  dalgoda@ix.netcom.com  and be right all the time, or not work at all
www.netcom.com/~dalgoda/ and be right at least twice a day.  -- mrc
    We are all of us living in the shadow of Manhattan.  -- Watchmen

Re: DESC

From
Rynell Wesson
Date:
See comments below.

On Wed, 22 Nov 2000, Mike Castle wrote:

> On Wed, Nov 22, 2000 at 06:38:15PM +0100, Albert REINER wrote:
> > And if you start psql with option -E you will see the actual
> > SQL-queries used by \d.
>
> That's nifty.  I've read through all of the pgsql documentation before
> starting everything, but I think I'm suffering a bit from information
> overload.  I knew this information was somewhere, I just couldn't remember
> where.
>
> So, thanks to all who pointed me to \d.
>
> Ok then.  It looks to me like both "DESC" and "DESCRIBE" are SQL keywords.
> DESC apparently is meant for descending, so I'm guessing that Oracle's
> sqlplus usage of DESC is an extension.  Is that correct?

DESC and ASC are SQL keywords used with the ORDER BY keywords for
listing values in descending and ascending order,
respectively.  DESC(RIBE) within an Oracle sqlplus session does not
conflict with the SQL DESC keyword.  DESC when used within an sqlplus
session will display a specified table's definition.  One version of
DESC is used within SQL DML statements, like SELECT <statement>, and the
other is used as a utility within an sqlplus session, just like any
utility found within a Unix shell (e.g. ls, find, echo, etc.).

>
> If so, is "DESCRIBE" the ANSI command that should do what \d does or does
> it serve another purpose in ANSI?  (A pointer as to where to find this
> explicitly would be nice; will eventually purchase the standard myself).
>

This version of DESCRIBE is for use within embedded SQL programs (C/C++).
More specifically, it is used with dynamic SQL select statements within
embedded SQL programs and it must be used after the dynamic SQL statement
has been compiled using the PREPARE statement.

> If DESCRIBE is supposed to do that, is there any reason that pgsql doesn't
> do that outside of "\d works, so no one has bothered to implement it."
>

I haven't written any embedded SQL programs using the traditional EXEC SQL
formats (I usually use libpq/libpq++ or JDBC) within PostgreSQL, but
PostgreSQL should be able to handle the DESCRIBE statement within embedded
SQL programs if it adhered to the embedded SQL specfications for C
utilizing EXEC SQL syntax.

I hope that I interpreted your questions correctly and I haven't stated
too much or too little in answering them and that all of this will give
you a better understanding.

Thanks.

Rynell Wesson