Return-Path: owner-postman Received: from localhost.Berkeley.EDU (localhost.Berkeley.EDU [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id RAA09248 for postgres-redist; Thu, 4 Aug 1994 17:21:43 -0700 Resent-From: POSTGRES mailing list Resent-Message-Id: <199408050021.RAA09248@nobozo.CS.Berkeley.EDU> X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost.Berkeley.EDU didn't use HELO protocol Sender: owner-postman@postgres.Berkeley.EDU X-Return-Path: owner-postman Received: from kitsune.swcp.com (kitsune.swcp.com [198.59.115.2]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with ESMTP id RAA09238 for ; Thu, 4 Aug 1994 17:21:41 -0700 Received: (from cheeks@localhost) by kitsune.swcp.com (8.6.9/8.6.9) id SAA26157; Thu, 4 Aug 1994 18:20:53 -0600 Date: Thu, 4 Aug 1994 18:20:53 -0600 From: Mark Costlow Message-Id: <199408050020.SAA26157@kitsune.swcp.com> To: stewart@oec.com CC: postgres@postgres.Berkeley.EDU In-reply-to: (stewart@oec.com) Subject: gleaning the database structure Resent-To: postgres-redist@postgres.Berkeley.EDU Resent-Date: Thu, 04 Aug 94 17:21:43 -0700 Resent-XMts: smtp On Thu, 4 Aug 1994 17:57:57 -0400 (EDT), Stewart Allen said: Stewart> Is there a simple set of queries which would provide basic Stewart> table/column structure information within a database? Here are a few queries that I worked up to do this. I built these by looking at the code for pg_relshow (in the contributed software that comes with Postgres). ------------------------------------ To get the list of databases: retrieve (pg_database.datname) ------------------------------------ Get the list of tables in the current database: retrieve (pg_class.relname) where pg_class.relname !~ "^pg_" ------------------------------------ Get the list of attributes for a table ("mailees" in this example): retrieve (FieldNum = a.attnum, FieldName = a.attname, Type = t.typname) from c in pg_class, a in pg_attribute, t in pg_type where c.relname = "mailees" and c.oid = a.attrelid and a.attnum > 0 and t.oid = a.atttypid sort by FieldNum using < ------------------------------------ >>Chx -- Mark Costlow Southwest Cyberport - Public Access Internet in Albuquerque, NM Email: cheeks@swcp.com Voice: 505-271-0009 ============================================================================== To add/remove yourself to/from the POSTGRES mailing list: send mail with the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU" If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and a human will deal with it. DO NOT post to the "postgres" mailing list. ==============================================================================