From: John DeSoi <desoi@pgedit.com>
To: S balasankaravadivel <bsvssa@yahoo.co.in>
Cc: pgsql-sql@postgresql.org
Subject: Re: doubt
Date: Sat, 19 May 2007 21:01:35 -0400
Message-ID: <16A4470D-6A0D-4BE8-815C-2A145C675D87@pgedit.com> (raw)
In-Reply-To: <979497.84014.qm@web8707.mail.in.yahoo.com>
References: <979497.84014.qm@web8707.mail.in.yahoo.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: desoi@pgedit.com, bsvssa@yahoo.co.in
Subject: Re: doubt
In-Reply-To: <16A4470D-6A0D-4BE8-815C-2A145C675D87@pgedit.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox