On Wed, Dec 2, 2015 at 4:29 PM, R Smith <rsmith at rsweb.co.za> wrote:
>
> Personally I use VARCHAR(Len) in table column definitions - simply because
> my schema is then directly interchangeable with MySQL/PostGres and the
> SQLite query planner sometimes notes that length when considering data
> shape - but for data purposes, SQLite doesn't care and neither do any
> wrappers I know of. Also, I can't imagine Excel would have an issue,
> whether referencing a data object via VB Script or OLE DB table import etc,
> I have never seen it matter in Excels 2003 through 2013.


I discourage this kind of usage because it means that in some distant
future when someone has to make things work with a different database
engine, they have to grind through and check every weirdo VARCHAR(73) and
MEDIUMBIGINT declaration someone put in, because none of them have ever
been tested with range enforcement enabled.  So where someone meant
"VARCHAR(256)" but actually typed "VARCHAR(6)", will your code suddenly
start throwing clean errors which immediately suggest where to look, or
will it just muddle through corrupting your data?  There can certainly be
subtle issues in any type, but my experience is that when you're trying to
decode someone's code, it's easiest when the code says what is actually
happening, not what it wishes were happening!

Of course, if you are _currently_ writing cross-platform code, absolutely
write the cross-platform code!  And I will agree that the above position
has some issues when faced with things such as INT being 32 bits on some
platforms, which I guess would argue for using BIGINT and BIGTEXT.  Unless
you need VARCHAR(MAX) or LONGTEXT, but maybe MEDIUMTEXT is more portable
... and pretty soon you give up and just circle back to not decorating with
unused/unchecked type annotations.

-scott

Reply via email to