Thread: SQL question

SQL question

From
"Guillaume Houssay"
Date:
I found a way to have the list of all the tables for my database.
 
Now, I would like to get the name of the columns of any table.
I could not find the SQL command to do that.
 
Thank you for you help
 
 

Re: SQL question

From
Martijn van Oosterhout
Date:
On Mon, Jun 09, 2003 at 03:30:33PM +0200, Guillaume Houssay wrote:
> I found a way to have the list of all the tables for my database.
>
> Now, I would like to get the name of the columns of any table.
> I could not find the SQL command to do that.

In psql type \? to get a list of all the commands. In particular, \d
<tablename> is what you're looking for.

--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> "the West won the world not by the superiority of its ideas or values or
> religion but rather by its superiority in applying organized violence.
> Westerners often forget this fact, non-Westerners never do."
>   - Samuel P. Huntington

Attachment

Re: SQL question

From
Richard Huxton
Date:
On Monday 09 Jun 2003 2:30 pm, Guillaume Houssay wrote:
> I found a way to have the list of all the tables for my database.
>
> Now, I would like to get the name of the columns of any table.
> I could not find the SQL command to do that.
>
> Thank you for you help

In psql there are a number of backslash commands - you might find the
following useful:

\d
\dt
\dv
\d mytable1
\d my*

If you start psql with the -E flag you'll see the SQL that's used to run
these. See "man psql" or the manuals for more info.

--
  Richard Huxton