下表说明了连接器/ODBC 如何将服务器数据类型映射到默认的 SQL 和 C 数据类型。
表 5.16 连接器/ODBC 如何将 MySQL 数据类型映射到 SQL 和 C 数据类型
本机值 | 类型 | C型 |
---|---|---|
bigint unsigned |
SQL_BIGINT |
SQL_C_UBIGINT |
bigint |
SQL_BIGINT |
SQL_C_SBIGINT |
bit |
SQL_BIT |
SQL_C_BIT |
bit |
SQL_CHAR |
SQL_C_CHAR |
blob |
SQL_LONGVARBINARY |
SQL_C_BINARY |
bool |
SQL_CHAR |
SQL_C_CHAR |
char |
SQL_CHAR |
SQL_C_CHAR |
date |
SQL_DATE |
SQL_C_DATE |
datetime |
SQL_TIMESTAMP |
SQL_C_TIMESTAMP |
decimal |
SQL_DECIMAL |
SQL_C_CHAR |
double precision |
SQL_DOUBLE |
SQL_C_DOUBLE |
double |
SQL_FLOAT |
SQL_C_DOUBLE |
enum |
SQL_VARCHAR |
SQL_C_CHAR |
float |
SQL_REAL |
SQL_C_FLOAT |
int unsigned |
SQL_INTEGER |
SQL_C_ULONG |
int |
SQL_INTEGER |
SQL_C_SLONG |
integer unsigned |
SQL_INTEGER |
SQL_C_ULONG |
integer |
SQL_INTEGER |
SQL_C_SLONG |
long varbinary |
SQL_LONGVARBINARY |
SQL_C_BINARY |
long varchar |
SQL_LONGVARCHAR |
SQL_C_CHAR |
longblob |
SQL_LONGVARBINARY |
SQL_C_BINARY |
longtext |
SQL_LONGVARCHAR |
SQL_C_CHAR |
mediumblob |
SQL_LONGVARBINARY |
SQL_C_BINARY |
mediumint unsigned |
SQL_INTEGER |
SQL_C_ULONG |
mediumint |
SQL_INTEGER |
SQL_C_SLONG |
mediumtext |
SQL_LONGVARCHAR |
SQL_C_CHAR |
numeric |
SQL_NUMERIC |
SQL_C_CHAR |
real |
SQL_FLOAT |
SQL_C_DOUBLE |
set |
SQL_VARCHAR |
SQL_C_CHAR |
smallint unsigned |
SQL_SMALLINT |
SQL_C_USHORT |
smallint |
SQL_SMALLINT |
SQL_C_SSHORT |
text |
SQL_LONGVARCHAR |
SQL_C_CHAR |
time |
SQL_TIME |
SQL_C_TIME |
timestamp |
SQL_TIMESTAMP |
SQL_C_TIMESTAMP |
tinyblob |
SQL_LONGVARBINARY |
SQL_C_BINARY |
tinyint unsigned |
SQL_TINYINT |
SQL_C_UTINYINT |
tinyint |
SQL_TINYINT |
SQL_C_STINYINT |
tinytext |
SQL_LONGVARCHAR |
SQL_C_CHAR |
varchar |
SQL_VARCHAR |
SQL_C_CHAR |
year |
SQL_SMALLINT |
SQL_C_SHORT |