Trailing blanks longer than 6 would be truncated.
Code:
------------------------------ Commands Entered ------------------------------
CREATE TABLE test_alter_lenghth
( id INTEGER NOT NULL PRIMARY KEY
, str VARCHAR(80)
);
------------------------------------------------------------------------------
DB20000I The SQL command completed successfully.
------------------------------ Commands Entered ------------------------------
INSERT INTO test_alter_lenghth
VALUES
( 1 , 'abcd' )
, ( 2 , 'efghij' )
, ( 3 , NULL )
, ( 4 , 'klmn ' )
;
------------------------------------------------------------------------------
DB20000I The SQL command completed successfully.
------------------------------ Commands Entered ------------------------------
SELECT t.*
, LENGTH(str) str_len
FROM test_alter_lenghth t
;
------------------------------------------------------------------------------
ID STR STR_LEN
----------- -------------------------------------------------------------------------------- -----------
1 abcd 4
2 efghij 6
3 - -
4 klmn 8
4 record(s) selected.
------------------------------ Commands Entered ------------------------------
ALTER TABLE test_alter_lenghth
ALTER str SET DATA TYPE VARCHAR(6);
------------------------------------------------------------------------------
SQL0445W Value "klmn " has been truncated. SQLSTATE=01004
------------------------------ Commands Entered ------------------------------
SELECT t.*
, LENGTH(str) str_len
FROM test_alter_lenghth t
;
------------------------------------------------------------------------------
ID STR STR_LEN
----------- ------ -----------
1 abcd 4
2 efghij 6
3 - -
4 klmn 6
4 record(s) selected.