Defines a new rule on a table.
CREATE RULE name AS ON event TO object [ WHERE condition ] DO [ INSTEAD ] action action ::= NOTHING | query | ( query [; ...] ) | [ query [; ...] ]
The name of the new rule you are creating.
The event that triggers the rule. This parameter should be one of:
The name of a table, or the fully qualified name of a table column (e.g.,
A SQL condition evaluating to a value of type
boolean, which specifies when this rule should be used. This statement should not refer to a table; the only exception to this is that the condition may refer to the special
oldrelations, which represent the existing rows, and any new row data provided, respectively.
INSTEADkeyword; when used, the
actionis executed instead of the specified
event. Otherwise, the
actionexecutes before the
The query (or queries) that define the action to perform when the rule is triggered, and the condition is met. The query (or queries) can be any valid
NOTIFYstatements. Supply multiple queries by surrounding them in parentheses.
You may alternatively use the
NOTHINGkeyword instead of a query.
NOTHINGwill perform no action, and is only useful if you also specify the
action values, you are able to use the special
old relations to access column values from both the referenced ...