Обсуждение: programatically obtaining table layout

Поиск
Список
Период
Сортировка

programatically obtaining table layout

От
"Philip Rudling"
Дата:
Is there a way of getting the output of a \d tablename  from within a
program (like describe in mysql)

Although this works fine from the postgres command line, from within a
program I get:

ODBC Error Code = 00000 ()

Error while executing the query (non-fatal); ERROR: parser: parse error at
or near "\"


SQL = "\d orders"

Data Source = "MESSINA"


The error occurred while processing an element with a general identifier of
(CFQUERY), occupying document position (4:1) to (7:39) in the template file
/usr/local/apache/htdocs/stephen/messina/TESTER.cfm.



I am using coldfusion and unix ODBC driver.



SR




Re: programatically obtaining table layout

От
"Mark McEahern"
Дата:
> Is there a way of getting the output of a \d tablename  from within a
> program (like describe in mysql)

If I understand your question correctly, you mean how do I do what this
does:

  psql -c "\d $tablename" $dbname $username

Try this:

  psql --help

Notice the -E option:

  -E              Display queries that internal commands generate

So:

  psql -c "\d $tablename" -E $dbname $username

Cheers,

// mark

-