From 455891bf96f6ee3dda9150fe83af2be5e86a572b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 3 Jul 2003 16:34:26 +0000 Subject: Code review for UPDATE tab SET col = DEFAULT patch ... whack it around so it has some chance of working in rules ... --- doc/src/sgml/ref/insert.sgml | 6 +++--- doc/src/sgml/ref/update.sgml | 37 ++++++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 14 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/insert.sgml b/doc/src/sgml/ref/insert.sgml index d2e29a8757..cbb0d279bd 100644 --- a/doc/src/sgml/ref/insert.sgml +++ b/doc/src/sgml/ref/insert.sgml @@ -1,5 +1,5 @@ @@ -33,7 +33,7 @@ INSERT INTO table [ ( The columns in the target list may be listed in any order. Each column not present in the target list will be inserted - using a default value, either a declared default value + using a default value, either its declared default value or null. @@ -77,7 +77,7 @@ INSERT INTO table [ ( DEFAULT VALUES - All columns will be filled their default values. + All columns will be filled with their default values. diff --git a/doc/src/sgml/ref/update.sgml b/doc/src/sgml/ref/update.sgml index 02cc07b0bd..1fe85b995e 100644 --- a/doc/src/sgml/ref/update.sgml +++ b/doc/src/sgml/ref/update.sgml @@ -1,5 +1,5 @@ @@ -28,7 +28,8 @@ UPDATE [ ONLY ] table SET UPDATE changes the values of the specified columns in all rows that satisfy the condition. Only the columns to - be modified need appear as columns in the statement. + be modified need be mentioned in the statement; columns not explicitly + SET retain their previous values. @@ -41,8 +42,9 @@ UPDATE [ ONLY ] table SET You must have the UPDATE privilege on the table to update it, as well as the SELECT - privilege to any table whose values are read in the condition. + privilege to any table whose values are read in the + expressions or + condition. @@ -72,7 +74,8 @@ UPDATE [ ONLY ] table SET expression - An expression or value to assign to the column. + An expression to assign to the column. The expression may use the + old values of this and other columns in the table. @@ -81,7 +84,8 @@ UPDATE [ ONLY ] table SET DEFAULT - This column will be filled with its default value. + Set the column to its default value (which will be NULL if no + specific default expression has been assigned to it). @@ -91,7 +95,7 @@ UPDATE [ ONLY ] table SET A list of table expressions, allowing columns from other tables - to appear in the WHERE condition. + to appear in the WHERE condition and the update expressions. @@ -100,9 +104,9 @@ UPDATE [ ONLY ] table SET condition - A value expression that returns a value of type - boolean that determines the rows which are to be - updated. + An expression that returns a value of type boolean. + Only rows for which this expression returns true + will be updated. @@ -135,9 +139,20 @@ UPDATE [ ONLY ] table SET kind of the table films: -UPDATE filme SET kind = 'Dramatic' WHERE kind = 'Drama'; +UPDATE films SET kind = 'Dramatic' WHERE kind = 'Drama'; + + + Adjust temperature entries and reset precipitation to its default + value in one row of the table weather: + + +UPDATE weather SET temp_lo = temp_lo+1, temp_hi = temp_lo+15, prcp = DEFAULT + WHERE city = 'San Francisco' AND date = '2003-07-03'; + + + -- cgit v1.2.1