Developing a Schema

From: "Steven Pennie" <Steven(at)ksdot(dot)org>
To: <pgsql-admin(at)postgresql(dot)org>
Subject: Developing a Schema
Date: 2000-02-23 15:45:55
Message-ID: s8b3ac5d.087@165.201.21.73
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I am working on SQLs to be used to develope a "schema" of whatever database I am using. I thought I would start by mimicing the "\d" command and build on from there. What is the SQL that generates the "\d" description? What I have so far is:
SELECT relname,typrelid,attname,tableowner,relowner,
reltype,reltuples,relhasindex,relukeys,relfkeys,relhasrules
FROM pg_class c, pg_tables t, pg_type y, pg_attribute a
WHERE relname NOT LIKE 'pg_%' AND relname=tablename AND
typname=relname AND attrelid=typrelid AND attnum > 0
ORDER BY relname;"

I noticed that pg_class.reltuples didn't always gave me the number of rows in a table, several times it had 1000 instead

Steven Pennie
Application Programmer/Analyst III
KDOT Materials & Research Center
(785) 291-3863 - Fax (785) 296-2526
steven(at)ksdot(dot)org

Browse pgsql-admin by date

  From Date Subject
Next Message Hernan J. Gonzalez 2000-02-23 21:01:30 bug with serial field?
Previous Message Peter Vazsonyi 2000-02-23 12:34:04 more performance on some aggregates