PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Lee Falkenhagen <falkenl at crl dot com>
Subject: Re: Size of null char field
Date: Apr 28 1998 8:08PM

Sybase stores null fields as varchars.  That means, if you define a 
column as char(3) null, it still stores it as varchar.  Sybase uses one 
byte for each space in a character field.  It also stores one byte if the 
field is null.  In other words, if you have a field that is char(3) null 
vs char(3) not null, the first uses 4 bytes and the second uses 3 bytes 
if the field is completely filled.  However, if the char(3) null only has 
a value of "I", than only two bytes are used.

I am doing this off the top of my head.  Check sybooks.sybase.com and 
look in the Reference Guide for exact storage requirements under "Data 
Types".

Lee Falkenhagen
Certified Sybase Professional
falkenl@hotmail.com

On Tue, 28 Apr 1998, Michael Peppler wrote:

> Mick Ghazey writes:
>  > How big is a char field that allows nulls? The reason I ask is because
>  > sybperl returns trailing spaces to fill out the column to the declared
>  > width for not null fields. Yet it returns only the actual string for
>  > null fields. Does that imply that sybase uses less disk space for null
>  > fields?
> 
> As I believe others have reported, Sybase stores nullable char fields
> as varchars, which is the reason why they don't get padded with ' ' to 
> the actual maximum width. I'm not 100% sure if varchar fields use less 
> space than char fields, but I think so (at least if they are not
> completely filled...)
> 
> Michael
> -- 
> Michael Peppler         -||-  Data Migrations Inc.
> mpeppler@datamig.com    -||-  http://www.mbay.net/~mpeppler
> Int. Sybase User Group  -||-  http://www.isug.com
> 
>