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 pointBy default mapping to QString
DOUBLE PRECISION64-bit Double-precision floating pointBy default mapping to QString
FLOAT64-bit Double-precision floating pointBy default mapping to QString
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 pointBy default mapping to QString
FLOAT64-bit floating pointBy default mapping to QString
DOUBLE64-bit floating pointBy default mapping to QString
DOUBLE PRECISION64-bit Double-precision floating pointBy default mapping to QString
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 PointBy default mapping to QString
DOUBLE64-bit Floating PointBy default mapping to QString
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 REALBy default mapping to QString
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 pointBy default mapping to QString
FLOAT64-bit Double floating pointBy default mapping to QString
DOUBLE64-bit Double floating pointBy default mapping to QString
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 pointBy default mapping to QString
DOUBLE PRECISION64-bit variable-precision floating pointBy default mapping to QString
DECIMAL VARIABLEuser-specified precision, exactMapped to QString
NUMERIC VARIABLEuser-specified precision, exactMapped to QString
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.By default mapping to QString
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

Sybase Adaptive Server Data Types

Sybase Adaptive Server data typeSQL type descriptionRecommended input (C++ or Qt data type)
BINARYDescribes a fixed-length binary value up to 255 bytes in size.Mapped to QByteArray
CHARCharacter StringMapped to QString
DATETIMEDate and time. Range: 1753-01-01 00:00:00 through 9999-12-31 23:59:59.Mapped to QDateTime
NCHARCharacter String of fixed lengthMapped to QString
NVARACHARCharacter String of variable lengthMapped to QString
VARCHARCharacter String of fixed lengthMapped to QString
CLOBCharacter large string objectMapped to QString
TIMESTAMPA unique number within a databaseMapped to QString
SMALLDATETIMEDate and time. Range: 1900-01-01 00:00 through 2079-12-31 23:59Mapped to QDateTime
UNICHARCharacter String of fixed length.(Unicode)Mapped to QString
UNIVARCHARCharacter String of variable length.(Unicode)Mapped to QString
VARBINARYDescribes a variable-length binary value up to 255 bytes in sizeMapped to QByteArray

SQLite Version 2

SQLite version 2 is "typeless". This means that you can store any kind of data you want in any column of any table, regardless of the declared data type of that column. We recommend that you map the data to QString.

© 2017 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.