Unix Technical Forum

doubt

This is a discussion on doubt within the pgsql Sql forums, part of the PostgreSQL category; --> Shall i use \d command from the c program. If possible give me a example program. Office firewalls, cyber ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 04:25 PM
S balasankaravadivel
 
Posts: n/a
Default doubt

Shall i use \d command from the c program. If possible give me a example program.




Office firewalls, cyber cafes, college labs, don't allow you to download CHAT? Click here: http://in.messenger.yahoo.com/webmessengerpromo.php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 04:25 PM
John DeSoi
 
Posts: n/a
Default Re: doubt

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


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:49 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com