Quote:
|
Originally Posted by itsonlyme44
Can I increase the length of a column without affecting the data??
|
Code:
ALTER TABLE ALTER COLUMN colname SET DATATYPE VARCHAR(1000)
(At least, when you are on DB2 v8 for z/OS or later; not sure whether this is possible on other platforms.)
Suppose the original datatype is CHAR(100); the data will be preserved, that is,
all varchar fields will have a length of 100 (i.e., possibly with blanks at the end), but after the ALTER, updated or inserted fields may be of lengths between 0 and 1000. (Or chose anything else than 1000.)
Similarly, a CHAR(100) or a VARCHAR(100) may be altered into a CHAR(1000); the new length must be at least the old length.