From: | John DeSoi <desoi(at)pgedit(dot)com> |
---|---|
To: | S balasankaravadivel <bsvssa(at)yahoo(dot)co(dot)in> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: doubt |
Date: | 2007-05-20 01:01:35 |
Message-ID: | 16A4470D-6A0D-4BE8-815C-2A145C675D87@pgedit.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 ON n.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
From | Date | Subject | |
---|---|---|---|
Next Message | Sabin Coanda | 2007-05-22 07:03:28 | system table storing sequence attributes |
Previous Message | chester c young | 2007-05-19 23:58:13 | Re: ignoring primary key violations in COPY command |