X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5BA9CD1B52F for ; Sat, 10 Jan 2004 04:07:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 39223-05 for ; Sat, 10 Jan 2004 00:07:04 -0400 (AST) Received: from smtp013.mail.yahoo.com (smtp013.mail.yahoo.com [216.136.173.57]) by svr1.postgresql.org (Postfix) with SMTP id D3262D1B430 for ; Sat, 10 Jan 2004 00:07:03 -0400 (AST) Received: from unknown (HELO IVESIA67) (sgnerd@203.196.190.138 with login) by smtp013.mail.yahoo.com with SMTP; 10 Jan 2004 04:07:01 -0000 Message-ID: <005f01c3d72e$c66919f0$7502a8c0@hdsc.com> Reply-To: "Kumar" From: "Kumar" To: "scott.marlowe" , "Bing Du" Cc: References: Subject: Re: how to show table structure? Date: Sat, 10 Jan 2004 09:33:51 +0530 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/78 X-Sequence-Number: 16471 use this Last login: Fri Jan 9 16:54:14 from 192.168.2.117 [ssakkaravel@Linuxsvr ssakkaravel]$ psql -E training test ********* QUERY ********** SELECT usesuper FROM pg_user WHERE usename = 'test' ************************** Welcome to psql, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help on internal slash commands \g or terminate with semicolon to execute query \q to quit training=# \d books ********* QUERY ********** SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules FROM pg_class WHERE relname='books' ************************** ********* QUERY ********** SELECT a.attname, format_type(a.atttypid, a.atttypmod), a.attnotnull, a.atthasdef, a.attnu m FROM pg_class c, pg_attribute a WHERE c.relname = 'books' AND a.attnum > 0 AND a.attrelid = c.oid ORDER BY a.attnum ************************** ********* QUERY ********** SELECT substring(d.adsrc for 128) FROM pg_attrdef d, pg_class c WHERE c.relname = 'books' AND c.oid = d.adrelid AND d.adnum = 1 ************************** Table "books" Column | Type | Modifiers -------------+-----------------------+-------------------------------------- -------------- -- bid | integer | not null default nextval('test.books_bid_seq'::text ) bname | character varying(20) | price | money | publication | date | ----- Original Message ----- From: "scott.marlowe" To: "Bing Du" Cc: Sent: Saturday, January 10, 2004 4:40 AM Subject: Re: [SQL] how to show table structure? > On Fri, 9 Jan 2004, Bing Du wrote: > > > Greetings, > > > > How can I see the layout of a table in PostgreSQL 7.4? I've checked > > several books and on-line documents, but was not able to figure out how > > PostgreSQL does 'describe ' like it's done in other databases. > > If in psql, use the \d commands (\? will show you all of them. > > However, if you've not got psql to do it, you can look through the > information_schema for anything like that, like so: > > select * from information_schema.tables; > > and so on. > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org