Data Types for Qt-supported Database Systems

This table shows the recommended data types for extracting data from the databases supported in Qt. Note that types used in Qt are not necessarily valid as input types to a specific database system. e.g., A double might work perfectly as input for floating point records in a particular database, but not necessarily as a storage format for output from that database, because it would be stored with 64-bit precision in C++.

IBM DB2 Data Types

IBM DB2 data typeSQL type descriptionRecommended input (C++ or Qt data type)
SMALLINT16-bit signed integertypedef qint16
INTEGER32-bit signed integertypedef qint32
BIGINT64-bit signed integertypedef qint64
REAL32-bit Single-precision floating pointtypedef qreal
DOUBLE PRECISION64-bit Double-precision floating pointMapped to QString for high precision doubles, otherwise qreal
FLOAT64-bit Double-precision floating pointtypedef qreal
CHARFixed-length, null-terminated character stringMapped to QString
VARCHARNull-terminated varying length stringMapped to QString
LONG VARCHARNot null-terminated varying length character stringMapped to QString
BLOBNot null-terminated varying binary string with 4-byte string length indicatorMapped to QByteArray
CLOBCharacter large string objectMapped to QString
DATENull-terminated character string of the following format: yyyy-mm-ddMapped to QDate
TIMENull-terminated character string of the following format: hh.mm.ssMapped to QTime
TIMESTAMPNull-terminated character string of the following format: yyyy-mm-dd-hh.mm.ss.nnnnnnMapped to QDateTime

Borland InterBase Data Types

Borland InterBase data typeSQL type descriptionRecommended input (C++ or Qt data type)
BOOLEANBooleanbool
TINYINT8 bit signed integertypedef qint8
SMALLINT16-bit signed integertypedef qint16
INTEGER32-bit signed integertypedef qint32
BIGINT LONG64-bit signed integertypedef qint64
REAL FLOAT32-bit floating pointtypedef qreal
FLOAT64-bit floating pointtypedef qreal
DOUBLE64-bit floating pointtypedef qreal
DOUBLE PRECISION64-bit Double-precision floating pointMapped to QString for high precision doubles, otherwise qreal
VARCHAR STRINGCharacter string, UnicodeMapped to QString
CLOBCharacter large string objectMapped to QString
DATEDisplays date. Format: 'yyyy-mm-dd'Mapped to QDate
TIMEDisplays time. Format is 'hh:mm:ss' in 24-hour formatMapped to QTime
TIMESTAMPDisplays a timestamp. Format is 'yyyy-mm-dd hh:mm:ss'Mapped to QDateTime

MySQL Data Types

MySQL data typeSQL type descriptionRecommended input (C++ or Qt data type)
TINYINT8 bit signed integertypedef qint8
TINYINT UNSIGNED8 bit unsigned integertypedef quint8
SMALLINT16-bit signed integertypedef qint16
SMALLINT UNSIGNED16-bit unsigned integertypedef quint16
INT32-bit signed integertypedef qint32
INT UNSIGNED32-bit unsigned integertypedef quint32
BIGINT64-bit signed integertypedef qint64
FLOAT32-bit Floating Pointtypedef qreal
DOUBLE64-bit Floating PointMapped to QString for high precision doubles, otherwise qreal
CHARCharacter stringMapped to QString
VARCHARCharacter stringMapped to QString
TINYTEXTCharacter stringMapped to QString
TEXTCharacter stringMapped to QString
MEDIUMTEXTCharacter stringMapped to QString
LONGTEXTCharacter stringMapped to QString
CLOBCharacter large string objectMapped to QString
all BLOB typesBLOBMapped to QByteArray
DATEDate without TimeMapped to QDate
DATETIMEDate and TimeMapped to QDateTime
TIMESTAMPDate and TimeMapped to QDateTime
TIMETimeMapped to QTime
YEARYear (int)Mapped to QDateTime
ENUMEnumeration of Value SetMapped to QString

Oracle Call Interface Data Types

Oracle Call Interface data typeSQL type descriptionRecommended input (C++ or Qt data type)
NUMBERFLOAT, DOUBLE, PRECISIONc REALMapped to QString for high precision doubles, otherwise qreal
NUMBER(38)INTEGER INT SMALLINTtypedef qint8/16/32/64
NUMBER(p,s)NUMERIC(p,s) DECIMAL(p,s)aBy default mapping to QString
NVARCHAR2(n)Character string (NATIONAL CHARACTER VARYING(n) NATIONAL CHAR VARYING(n) NCHAR VARYING(n))Mapped to QString
NCHAR(n)Character string (NATIONAL CHARACTER(n) NATIONAL CHAR(n) NCHAR(n))Mapped to QString
CHAR(n)Character string (CHARACTER(n) CHAR(n))Mapped to QString
CLOBCharacter large string objectMapped to QString
BLOBA binary large objectMapped to QByteArray
TIMESTAMPYear, month, and day values of date, as well as hour, minute, and second values of timeMapped to QDateTime

ODBC Data Types

ODBC data typeSQL type descriptionRecommended input (C++ or Qt data type)
BITBooleanBOOL
TINYINT8 bit integertypedef qint8
SMALLINT16-bit signed integertypedef qint16
INTEGER32-bit signed integertypedef qint32
BIGINT64-bit signed integertypedef qint64
REAL32-bit Single-precision floating pointtypedef qreal
FLOAT64-bit Double floating pointtypedef qreal
DOUBLE64-bit Double floating pointMapped to QString for high precision doubles, otherwise qreal
CHARCharacter stringMapped to QString
VARCHARCharacter stringMapped to QString
LONGVARCHARCharacter stringMapped to QString
CLOBCharacter large string objectMapped to QString
DATECharacter stringMapped to QDate
TIMECharacter Time, Character stringMapped to QTime
TIMESTAMPCharacter Time, Character stringMapped to QDateTime

PostgreSQL Data Types

PostgreSQL data typeSQL type descriptionRecommended input (C++ or Qt data type)
BOOLEANBooleanbool
SMALLINT16-bit signed integertypedef qint16
INTEGER32-bit signed integertypedef qint32
BIGINT64-bit signed integertypedef qint64
REAL32-bit variable-precision floating pointtypedef qreal
DOUBLE PRECISION64-bit variable-precision floating pointMapped to QString for high precision doubles, otherwise qreal
DECIMAL VARIABLEuser-specified precision, exacttypedef qreal
NUMERIC VARIABLEuser-specified precision, exacttypedef qreal
VARCHARvariable-length character stringMapped to QString
CHARACTERCharacter string of fixed-lengthMapped to QString
TEXTCharacter string of variable-lengthMapped to QString
CLOBCharacter large string objectMapped to QString
TIMESTAMP8 bytes, both date and timeMapped to QDateTime
TIMESTAMP8 bytes, both date and time, with time zoneMapped to QDateTime
DATE4 bytes, dates onlyMapped to QDate
TIME8 bytes, times of day only 00:00:00.00 - 23:59:59.99Mapped to QTime
TIME12 bytes times of day only, with time zone 00:00:00.00+12Mapped to QDateTime

QSQLITE SQLite version 3 Data Types

QSQLITE SQLite version 3 data typeSQL type descriptionRecommended input (C++ or Qt data type)
NULLNULL value.NULL
INTEGERSigned integer, stored in 8, 16, 24, 32, 48, or 64-bits depending on the magnitude of the value.typedef qint8/16/32/64
REAL64-bit floating point value.typedef qreal
TEXTCharacter string (UTF-8, UTF-16BE or UTF-16-LE).Mapped to QString
CLOBCharacter large string objectMapped to QString
BLOBThe value is a BLOB of data, stored exactly as it was input.Mapped to QByteArray

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.