Search Postgresql Archives

Adding a default value to a column after it exists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 with the default, shunt all the values in the temp column over to the new column and then drop the temp column.  But I have before and after triggers on the table that react to changes in this column (not to mention the need for it's existence). 

 

I could add something to the before trigger to do this too. But it would be cleaner to do this as a column property.

 

Thanks for any help.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux