From 8f60f43f2e23add472acd988741411e025bff87d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 2 Sep 2002 20:04:40 +0000 Subject: Department of second thoughts: make checks for replacing a view slightly more flexible, and improve the error reporting. Also, add documentation for REPLACE RULE/VIEW. --- doc/src/sgml/ref/create_rule.sgml | 25 ++++++++++++++++--------- doc/src/sgml/ref/create_view.sgml | 21 ++++++++++++++++++--- doc/src/sgml/release.sgml | 3 ++- 3 files changed, 36 insertions(+), 13 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/create_rule.sgml b/doc/src/sgml/ref/create_rule.sgml index 86046359b4a..998d075a645 100644 --- a/doc/src/sgml/ref/create_rule.sgml +++ b/doc/src/sgml/ref/create_rule.sgml @@ -1,5 +1,5 @@ @@ -21,17 +21,15 @@ PostgreSQL documentation 2001-01-05 -CREATE RULE name AS ON event +CREATE [ OR REPLACE ] RULE name AS ON event TO table [ WHERE condition ] DO [ INSTEAD ] action where action can be: NOTHING -| -query -| -( query ; query ... ) +| query +| ( query ; query ... ) @@ -76,9 +74,10 @@ NOTHING condition - Any SQL conditional expression (returning boolean). The condition expression may not + Any SQL conditional expression (returning boolean). + The condition expression may not refer to any tables except new and - old. + old, and may not contain aggregate functions. @@ -142,6 +141,14 @@ CREATE RULE Description + + CREATE RULE defines a new rule applying to a specified + table or view. + CREATE OR REPLACE RULE will either create a + new rule, or replace an existing rule of the same name for the same + table. + + The PostgreSQL rule system allows one to define an @@ -318,7 +325,7 @@ UPDATE mytable SET name = 'foo' WHERE id = 42; - CREATE RULE statement is a PostgreSQL + CREATE RULE is a PostgreSQL language extension. There is no CREATE RULE statement in SQL92. diff --git a/doc/src/sgml/ref/create_view.sgml b/doc/src/sgml/ref/create_view.sgml index aa7c869285f..1692f9f0f77 100644 --- a/doc/src/sgml/ref/create_view.sgml +++ b/doc/src/sgml/ref/create_view.sgml @@ -1,5 +1,5 @@ @@ -21,7 +21,7 @@ PostgreSQL documentation 2000-03-25 -CREATE VIEW view [ ( view [ ( column name list ) ] AS SELECT query @@ -132,13 +132,21 @@ CREATE VIEW vista AS SELECT text 'Hello World' Description + - CREATE VIEW will define a view of a query. + CREATE VIEW defines a view of a query. The view is not physically materialized. Instead, a query rewrite rule (an ON SELECT rule) is automatically generated to support SELECT operations on views. + + CREATE OR REPLACE VIEW is similar, but if a view + of the same name already exists, it is replaced. You can only replace + a view with a new query that generates the identical set of columns + (i.e., same column names and data types). + + If a schema name is given (for example, CREATE VIEW myschema.myview ...) then the view is created in the @@ -206,6 +214,7 @@ SELECT * FROM kinds; SQL92 + SQL92 specifies some additional capabilities for the CREATE VIEW statement: @@ -253,6 +262,12 @@ CREATE VIEW view [ + + + CREATE OR REPLACE VIEW is a + PostgreSQL language extension. + + diff --git a/doc/src/sgml/release.sgml b/doc/src/sgml/release.sgml index 3ba21bc1ab7..d0fc445380c 100644 --- a/doc/src/sgml/release.sgml +++ b/doc/src/sgml/release.sgml @@ -1,5 +1,5 @@ @@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without worries about funny characters. -->