Search Postgresql Archives

Re: how do you get there from here?

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

 



Michael P. Soulier wrote:
> my $sql =<<EOF;
> ALTER TABLE instances ADD COLUMN udp_icpside_address_override inet
> DEFAULT NULL;
> ALTER TABLE instances ADD COLUMN udp_setside_address_override inet
> DEFAULT NULL;
> UPDATE instances SET udp_icpside_address_override =
> $udp_icpside_address_override;
> UPDATE instances SET udp_setside_address_override =
> $udp_setside_address_override;
> ALTER TABLE instances DROP COLUMN public_ip;
> ALTER TABLE instances DROP COLUMN public_ip_override;
> ALTER TABLE instances DROP COLUMN lan_mode;

Ok, using the default to set the value on the new column seems to avoid
this...

my $sql =<<EOF;
ALTER TABLE instances DROP COLUMN public_ip;
ALTER TABLE instances DROP COLUMN public_ip_override;
ALTER TABLE instances DROP COLUMN lan_mode;
ALTER TABLE instances ADD COLUMN udp_icpside_address_override inet
DEFAULT $udp_icpside_address_override;
ALTER TABLE instances ADD COLUMN udp_setside_address_override inet
DEFAULT $udp_setside_address_override;
ALTER TABLE instances ALTER COLUMN udp_icpside_address_override SET
DEFAULT NULL;
ALTER TABLE instances ALTER COLUMN udp_setside_address_override SET
DEFAULT NULL;
EOF

$dbh->do($sql);

But I don't understand why this was required. What's wrong with adding a
column and copying data into it in a transaction?

Mike

Attachment: signature.asc
Description: OpenPGP digital signature


[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