This section shows how different MySQL datatypes are mapped to Borland/CodeGear's TField descendants.
|MySQL datatypes||TField descedant|
|BIT, BIGINT||TLargeintField (see warning below)|
|TINYINT(1), BOOL, BOOLEAN||TSmallIntField or TBooleanField (see note #4 below)|
|MEDIUMINT, INT, INTEGER, YEAR||TIntegerField|
|FLOAT, DOUBLE, DECIMAL, DEC, FIXED||TFloatField|
|CHAR||TStringField (or TWideStringField, see note #1 below)|
|VARCHAR(<8192)||TStringField (or TWideStringField, see notes #1 and #2 below)|
|VARCHAR(>=8192)||TMemoField (or TWideMemoField, see notes #1 and #2 below)|
|BINARY, VARBINARY, TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB||TBlobField|
|TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT||TMemoField (or TWideMemoField, see notes #1 and #5 below)|
|ENUM('n','y'), ENUM('f','t')||TBooleanField or TStringField (see note #4 below)|
|other ENUM||TStringField (or TWideStringField, see note #1 below)|
|SET||TStringField (or TWideStringField, see note #1 below)|
TStringField and TMemoField can be replaced with TWideStringField and TWideMemoField respectively for Unicode-data in Delphi/C++Builder 2009. Please read this FAQ section if you want to use Unicode strings in your application: How can I use Unicode data in my application?
Be careful while working with Unicode encoded fields (e.g., utf8) in "pre-Delphi-2009" projects. These fields length is calculated in bytes, not in symbols. So varchar(3000) can contain from 3000 to 12000 bytes. This means that it can be mapped to TStringField or to TMemoField in different cases for "pre-Delphi-2009" projects.
If you want to use TNT Unicode Controls to implement Unicode support to your "pre-Delphi-2009" application you can use our free package with wrapper-components - Wrappers for TNT Unicode Controls. All string fields are mapped to TTNTStringField datatype with this package.
DAC for MySQL treats ENUM('n','y') or ENUM('f','t') MySQL datatypes as TBooleanField fields and TINYINT datatype as TSmallIntField by default. But MySQL Reference Manual says that BOOL and BOOLEAN datatypes are synonyms for TINYINT(1) and even defines TRUE (as 1) and FALSE (as 0) constants for it. You can let DAC for MySQL to treat BOOL, BOOLEAN and TINYINT(1) datatypes as TBooleanField by enabling M_BOOL_AS_INT conditional define in mySQLDAC.inc file and rebuilding DAC for MySQL packages. All ENUM fields are mapped to TStringField (or TWideStringField) fields in this case.
If you use 'utf8' character set and 'utf8_bin' collation for TINYTEXT, TEXT, MEDIUMTEXT or LONGTEXT column MySQL marks it with BINARY flag. This cause this columns to be mapped by DAC for MySQL to TBlobField rather then to TMemoField. This can break correct Unicode data handling in "Delphi-2009" projects. Please consider use 'utf8_general_ci' or 'utf8_unicode_ci' collation for MEMO columns for proper Unicode texts handling.
|Delphi 7 and prior has poor support for int64 values in variant type. This means
that you'll be unable to use Locate() and similar methods with such fields. Lookup fields and
master-detail tables will not work properly too because of their dependence on Locate() method.
Please update your IDE to BDS 2006 (or later) or don't use BIGINT and UNSIGNED INT datatypes
for keys and indexes if you need to use them in lookup fields. Also you can't use variant-style
properties (FieldValues, AsVariant and so on) with such fields.|