Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 0DC0C9FB3BB for ; Sat, 19 May 2007 22:01:47 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 60869-02 for ; Sat, 19 May 2007 22:01:26 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from a2s5.a2hosting.com (a2s5.a2hosting.com [209.124.50.10]) by postgresql.org (Postfix) with ESMTP id 7D7329FB3A4 for ; Sat, 19 May 2007 22:01:42 -0300 (ADT) Received: from adsl-6-54-34.tys.bellsouth.net ([65.6.54.34] helo=[192.168.1.12]) by a2s5.a2hosting.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1HpZno-0006CA-Hj; Sat, 19 May 2007 21:01:40 -0400 In-Reply-To: <979497.84014.qm@web8707.mail.in.yahoo.com> References: <979497.84014.qm@web8707.mail.in.yahoo.com> Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <16A4470D-6A0D-4BE8-815C-2A145C675D87@pgedit.com> Cc: pgsql-sql@postgresql.org Content-Transfer-Encoding: 7bit From: John DeSoi Subject: Re: doubt Date: Sat, 19 May 2007 21:01:35 -0400 To: S balasankaravadivel X-Mailer: Apple Mail (2.752.3) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - a2s5.a2hosting.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - pgedit.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/149 X-Sequence-Number: 28429 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