From 7946f77220bb960e7ba5ed2a9dfb84ac3f926b2f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 3 Aug 2006 20:57:06 +0000 Subject: Cause ALTER TABLE to perform ALTER COLUMN DROP DEFAULT operations during the DROP pass rather than the ADD_CONSTR pass. On examining the code I think this was just an oversight rather than intentional, and it seems to satisfy the principle of least surprise better than the alternative solution that was discussed. Add an example to the ref page showing how to do ALTER TYPE and update the default in one command. Per gripe from Markus Bertheau that that wasn't possible. --- doc/src/sgml/ref/alter_table.sgml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index c753eb63007..17b0f3667da 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -1,5 +1,5 @@ @@ -741,6 +741,19 @@ ALTER TABLE foo + + The same, when the column has a default expression that won't automatically + cast to the new datatype: + +ALTER TABLE foo + ALTER COLUMN foo_timestamp DROP DEFAULT, + ALTER COLUMN foo_timestamp TYPE timestamp with time zone + USING + timestamp with time zone 'epoch' + foo_timestamp * interval '1 second', + ALTER COLUMN foo_timestamp SET DEFAULT now(); + + + To rename an existing column: -- cgit v1.2.3