Re: How to see a RULE definition? - Mailing list pgsql-general

From Tom Lane
Subject Re: How to see a RULE definition?
Date
Msg-id 11755.979232278@sss.pgh.pa.us
Whole thread Raw
In response to How to see a RULE definition?  (Josh Goodman <jogoodma@lanl.gov>)
Responses Re: How to see a RULE definition?  (Jan Wieck <janwieck@Yahoo.com>)
List pgsql-general
Josh Goodman <jogoodma@lanl.gov> writes:
> ...  I was able to figure out that all the rules
> for a particular DB are stored in the pg_rewrite table but that seems
> almost unreadable for a human.  What I would like is a command that spits
> out the create syntax I used when the rule was first created.

See the (woefully undocumented) pg_get_ruledef() function.  pg_dump uses
this.

> On that
> same line of thinking, is there a command to get a list of all rules that
> have been put on a table?

A join of pg_rewrite against pg_class should do it for you ...

            regards, tom lane

pgsql-general by date:

Previous
From: "Trewern, Ben"
Date:
Subject: RE: How to see a RULE definition?
Next
From: "Trewern, Ben"
Date:
Subject: Recall: How to see a RULE definition?