Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Saving space with Varchar
Message
From
05/09/2008 22:36:10
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
05/09/2008 14:21:03
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01345228
Message ID:
01345303
Views:
16
>>I thought the varchar field type would save space in the file size of my table?
>>
>>I have a table that has thousands of records and many character fields, I thought by changing the character fields to varchar the table size would be reduced?
>>
>>Have I got this all wrong?
>
>The table size is not reduced. As I understand it, VFP VarChar is there mainly to improve interoperability with SQL Server. IIRC another effect is different handling of trailing spaces/column padding. See the help: "HELP FIELD TYPES" for VarChar, including the code sample.

The other difference is the length of the field, as returned by the len() function - it shouldn't include the padding, i.e. it would return the position of the rightmost character before the first chr(0). Seek() should also work differently - wherever we had implied padding with regular character fields, we may have strings of different lengths, or at least strings behaving as if of different lengths.

With varchar fields, you find

calc max(len(cfield)) to maxlen

there is no more the need for

calc max(len(trim(cfield))) to maxlen

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform