Currently, I have a DB2 database and some columns in char type.
If i insert some data to these columns with less characters than it’s specified, DB2 fillst the rest with blank characters.
For example:
Column: orderkey in type char(8)
If I insert "AB12", it is saved like "AB12XXXX" (X indicates the blank chracters)
Is ist possible to prevent that DB2 fills blank characters by char type?
DB2 Version 9.5
In SQL, the CHAR data type is a fixed length character string. By definition, the additional characters are padded wtih spaces.
What you want is the VARCHAR data type. So, just change your data type for VARCHAR(8) and it will store your strings with no appended spaces.
By the way, this is true in all databases, not only DB2.