GDA: string lengths (was Re: GDA save missing records)
David T.
sunfish62 at yahoo.com
Mon Feb 18 23:10:28 EST 2008
The different databases define and handle VARCHAR types differently.
MySQL documentation states:
"Values in VARCHAR columns are variable-length strings. The length can be
specified as a value from 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in 5.0.3
and later versions."
So, the valid lengths for VARCHAR type are dependent on the MySQL version, and
are variable, not padded.
PostgreSQL 8.3 documentation states:
"If one explicitly casts a value to character varying(n) [i.e. VARCHAR] or
character(n) [i.e. CHAR] , then an over-length value will be truncated to n
characters without raising an error. ... If character varying is used without
length specifier, the type accepts strings of any size. The latter is a
PostgreSQL extension."
So in PostgreSQL, if you specify a length, that's what gets stored, but if you
don't specify a length, anything goes.
SQLite states:
"SQLite does not enforce the length of a VARCHAR. You can declare a VARCHAR(10)
and SQLite will be happy to let you put 500 characters in it. And it will keep
all 500 characters intact - it never truncates."
So size definitions won't matter in SQLite.
Cheers,
David
--- Graham Leggett <minfrin at sharp.fm> wrote:
> Keith Bellairs wrote:
>
> > I think that depends on the DB. Using VARCHAR at least gives the engine
> > a chance to optimize storage. CHAR is good for truly fixed length strings.
>
> This is true, I mixed up the varchar with the char. Adding a limit to
> varchar is entirely arbitrary though, if the varchar can support a 2
> byte string length, then why not choose the biggest size available?
>
> Regards,
> Graham
> --
> > _______________________________________________
> gnucash-devel mailing list
> gnucash-devel at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel
>
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
More information about the gnucash-devel
mailing list