Thread: meaningful trigger descriptions

meaningful trigger descriptions

From
"Jason S. Friedman"
Date:
When one describes a table psql lists the foreign keys after the table columns, e.g.:

calendar=> \d business
                                        Table "business"
      Column      |            Type             |                   Modifiers

------------------+-----------------------------+-----------------------------------------------
 id               | integer                     | not null default nextval('business_id'::text)
 name             | character varying(100)      | not null
 owner            | character varying(100)      | not null
 address_line_1   | character varying(100)      | not null
 address_line_2   | character varying(100)      |
 city             | character varying(100)      | not null
 state_code       | character(2)                | not null
 zip              | character(5)                | not null
 zip_4            | character(4)                |
 primary_timezone | character(3)                | not null default 'GMT'
 create_date      | timestamp(0) with time zone | default now()
 last_update_date | timestamp(0) with time zone |
 create_by        | integer                     |
 last_update_by   | integer                     |
Primary key: business_pk
Unique keys: business_name_key,
             business_name_owner
Triggers: RI_ConstraintTrigger_56403390,
          RI_ConstraintTrigger_56403392,
          RI_ConstraintTrigger_56403426,
          RI_ConstraintTrigger_56403428,
          RI_ConstraintTrigger_56403514,
....

Does anyone have a query handy that will print out something prettier for those foreign key constraints, like:

tablename   constraint
----------------------
foo         FOREIGN KEY (a) REFERENCES bar
foo         FOREIGN KEY (b) REFERENCES goo
bar        q FOREIGN KEY (z) REFERENCES goo