MySQL 中的数据类型(INTEGER、DECIMAL、DATETIME) INTEGER:TINYINT、SMALLINT、MEDIUMINT、INT、BIGINT 对应的 C/C++类型:char、short、int、int、int64_t DECIMAL:FLOAT、DOUBLE、DECIMAL 对应的 C/C++类型:float、double、double==long double DATETIME:DATE、TIME、YEAR、DATETIME、TIMESTAMP 对应的 C/C++类型:struct tm、tm、int、tm、time_t
TINYINT -> char SMALLINT -> short MEDIUMINT -> int INT -> int BIGINT -> int64_t
FLOAT -> float DOUBLE -> double DECIMAL -> double、long double
DATE -> struct tm TIME -> tm YEAR -> int DATETIME -> tm TIMESTAMP -> time_t
struct tm
{
int tm_sec; // seconds after the minute - [0, 60] including leap second
int tm_min; // minutes after the hour - [0, 59]
int tm_hour; // hours since midnight - [0, 23]
int tm_mday; // day of the month - [1, 31]
int tm_mon; // months since January - [0, 11]
int tm_year; // years since 1900
int tm_wday; // days since Sunday - [0, 6]
int tm_yday; // days since January 1 - [0, 365]
int tm_isdst; // daylight savings time flag
};
NCHAR -> unsigned char* CHAR -> char* NVARCHAR -> unsigned char* VARCHAR -> char* TINYTEXT -> char[256] TEXT -> string MEDIUMTEXT -> string LONGTEXT -> string
BLOB、TINYBLOB、MEDIUMBLOB、LONGBLOB都对应char*类型
并没有一个标准的方法来转换 MySQL 数据到 C/C++的数据类型