Re: [GENERAL] Adding a default value to a column after it exists

2011-04-14 Thread Harald Fuchs
In article <20110413163120.gu24...@shinkuro.com>, Andrew Sullivan writes: > On Wed, Apr 13, 2011 at 09:21:20AM -0700, Gauthier, Dave wrote: >> Is there a way to add a default value definition to an existing column? >> Something like an "alter table... alter column... default 'foo'". > ALTER TA

Re: [GENERAL] Adding a default value to a column after it exists

2011-04-13 Thread Andrew Sullivan
On Wed, Apr 13, 2011 at 09:21:20AM -0700, Gauthier, Dave wrote: > Is there a way to add a default value definition to an existing column? > Something like an "alter table... alter column... default 'foo'". ALTER TABLE table ALTER [ COLUMN ] column SET DEFAULT expression (see http://www.postgres

Re: [GENERAL] Adding a default value to a column after it exists

2011-04-13 Thread Tom Lane
"Gauthier, Dave" writes: > Is there a way to add a default value definition to an existing column? > Something like an "alter table... alter column... default 'foo'". ALTER TABLE ... ALTER COLUMN ... SET DEFAULT ... regards, tom lane -- Sent via pgsql-general mailing

Re: [GENERAL] Adding a default value to a column after it exists

2011-04-13 Thread Mike Fowler
Hi Dave, On 13/04/11 17:21, Gauthier, Dave wrote: Is there a way to add a default value definition to an existing column? Something like an "alter table... alter column... default 'foo'". Sure is something like that: ALTER TABLE tablename ALTER COLUMN columnname SET DEFAULT expression;

[GENERAL] Adding a default value to a column after it exists

2011-04-13 Thread Gauthier, Dave
Is there a way to add a default value definition to an existing column? Something like an "alter table... alter column... default 'foo'". I thought of a clumsy way to do this... create a temp column, set it's value to that of the column to be altered, drop the column to be altered, redefine it