Reducing the file sizeI've changed a field in a file to be variable length. As most of the records have blanks in this field, I've set the minimum length to zero. I've recreated the file and copied the data back into it. I then updated the file using %TRIMR to trim the trailing blanks from the variable length field. I am expecting an 80% reduction in the file size, but it hasn't changed? I've used %LEN to check the internal length of the field and the trailing spaces have been removed. Why hasn't the file size reduced? I've even re-organized the file but with no effect. How do I get the object to release the unused storage? What am I doing wrong?
I know that I can write a conversion program to read in the old file, populate the new file, and get the desired outcome. But I was hoping my initial approach would work.
Before you trim out the trailing blanks, your variable length fields are stored in a secondary storage container that's part of your file object. Even though you update these variable length fields to a length of zero, all/some of this storage space in the secondary container is left for new variable length field values that will be added in future inserts, updates, and deletes. In addition, the usage of variable length fields add some additional overhead to each record to keep track of the location and length of variable length fields. Also, if your variable length field is 30 bytes or less, than DB2 may also ignore your Allocate setting.
MORE INFORMATION ON THIS TOPIC
Search400.com's targeted search engine: Get relevant information on DB2/400.
The Best Web Links: tips, tutorials and more.
Check out this Search400.com Featured Topic: Database issues resolved
Dig Deeper on DB2 UDB (universal databases)
Related Q&A from Kent Milligan
To solve the SQL error -321 on IBM i6.1, use the new values statement to overcome the error. If you are using an older release, declare a cursor ... Continue Reading
When working with DB2 files with columns that have both short and long names, there is no option choose which column names are returned via ODBC ... Continue Reading
When developing tables in a parent-child relationship, use a primary key and a foreign key along with a unique ID to make your database easier to ... Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.