Re: doubt

Поиск
Список
Период
Сортировка
От John DeSoi
Тема Re: doubt
Дата
Msg-id 16A4470D-6A0D-4BE8-815C-2A145C675D87@pgedit.com
обсуждение исходный текст
Ответ на doubt  (S balasankaravadivel <bsvssa@yahoo.co.in>)
Список pgsql-sql
On May 17, 2007, at 5:43 AM, S balasankaravadivel wrote:
> Shall i use \d command from the c program. If possible give me a  
> example program.


If you want to use the \d command in a C program, link your program  
to libpq and grab the C source code for the \d command from psql.

Also, if you just need to know the SQL used to generate the command  
output you can use the following command:

\set ECHO_HIDDEN 1

Now all the SQL used in psql commands will be displayed. The SQL for  
the \d command is


=== psql 5 ===
\d

********* QUERY **********
SELECT n.nspname as "Schema",  c.relname as "Name",  CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'i'

 
THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special' END as  
"Type",  r.rolname as "Owner"
FROM pg_catalog.pg_class c     JOIN pg_catalog.pg_roles r ON r.oid = c.relowner     LEFT JOIN pg_catalog.pg_namespace n
ONn.oid = c.relnamespace
 
WHERE c.relkind IN ('r','v','S','')      AND n.nspname NOT IN ('pg_catalog', 'pg_toast')  AND
pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1,2;
**************************
                  List of relations
Schema |           Name           |   Type   | Owner
--------+--------------------------+----------+-------
public | barcode                  | table    | user1
public | foo                      | table    | user1
public | foo_a_seq                | sequence | user1
(3 rows)


John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL



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

Предыдущее
От: chester c young
Дата:
Сообщение: Re: ignoring primary key violations in COPY command
Следующее
От: "Sabin Coanda"
Дата:
Сообщение: system table storing sequence attributes