Re: getting column names for tables..

Поиск
Список
Период
Сортировка
От Brett Schwarz
Тема Re: getting column names for tables..
Дата
Msg-id 1031619971.1692.35.camel@thor
обсуждение исходный текст
Ответ на getting column names for tables..  (jerome <jerome@gmanmi.tv>)
Список pgsql-general
set conn [pg_connect -conninfo "..."]
set res [pg_exec $conn "SELECT * FROM some_table"]
set attList [pg_result $res -attributes]

    .
    .
    .
pg_result $res -clear

Note that your select statement will determine *which* columns are
returned. The above is good if you want the actual tuples returned as
well. But if all you want are the attributes, then you could add a
"LIMIT 1" to the end of the SQL, or you could use this sql, and retrieve
the tuples (which will be the columns):

  SELECT A.attname
    FROM Pg_class C, Pg_attribute A
   WHERE C.oid = A.attrelid

I *think* that's it...I am doing it from memory. You may have to tweak
it...and I think 7.3 will be different if I recall...

HTH,

    --brett


On Tue, 2002-09-10 at 06:27, jerome wrote:
> im using pgtclsh is there a possibility to get column names for tables?
>
> TIA
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
--
Brett Schwarz
brett_schwarz AT yahoo.com


В списке pgsql-general по дате отправления:

Предыдущее
От: "oclam"
Дата:
Сообщение: Compare chinese words
Следующее
От: Josh Jore
Дата:
Сообщение: Psql regex is NFA or DFA?