Thread: Alter table alter column

Alter table alter column

From
Marc Munro
Date:
Am I right in thinking that altering a column from varchar(n) to
varchar(n+m) requires each tuple to be visited?

Recent experience suggests this is the case but my reading of the docs
has left me uncertain why this should be so.  We are not changing the
fundamental type of the column, nor are we attempting an operation that
will fail due to existing data being incompatible with the new
definition.

Is there some fundamental reason why placing a higher limit on the
length of existing data cannot be done solely by changing the system
catalogs?  Is this an optimisation that could be added to the TODO list?

__
Marc

Attachment

Re: Alter table alter column

From
Tom Lane
Date:
Marc Munro <marc@bloodnok.com> writes:
> Am I right in thinking that altering a column from varchar(n) to
> varchar(n+m) requires each tuple to be visited?

Yes.  Doing otherwise would require an unreasonable amount of
data-type-specific knowledge hardwired into ALTER COLUMN TYPE.

            regards, tom lane