Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
qsqldatatype-table.qdoc
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \page sql-types.html
6 \title Data Types for Qt-supported Database Systems
7 \brief Recommended data types for database systems
8
9 \section1 Recommended Data Types for Qt-Supported Database Systems
10
11 This table shows the recommended data types for extracting data from
12 the databases supported in Qt. Note that types used in Qt are not
13 necessarily valid as input types to a specific database
14 system. e.g., A double might work perfectly as input for floating
15 point records in a particular database, but not necessarily as a
16 storage format for output from that database, because it would be
17 stored with 64-bit precision in C++.
18
19 \tableofcontents
20
21 \section2 IBM DB2 Data Types
22
23 \table 90%
24 \header
25 \li IBM DB2 data type
26 \li SQL type description
27 \li Recommended input (C++ or Qt data type)
28 \row
29 \li SMALLINT
30 \li 16-bit signed integer
31 \li typedef qint16
32 \row
33 \li INTEGER
34 \li 32-bit signed integer
35 \li typedef qint32
36 \row
37 \li BIGINT
38 \li 64-bit signed integer
39 \li typedef qint64
40 \row
41 \li REAL
42 \li 32-bit Single-precision floating point
43 \li typedef qreal
44 \row
45 \li DOUBLE PRECISION
46 \li 64-bit Double-precision floating point
47 \li Mapped to QString for high precision doubles, otherwise qreal
48 \row
49 \li FLOAT
50 \li 64-bit Double-precision floating point
51 \li typedef qreal
52 \row
53 \li CHAR
54 \li Fixed-length, null-terminated character string
55 \li Mapped to QString
56 \row
57 \li VARCHAR
58 \li Null-terminated varying length string
59 \li Mapped to QString
60 \row
61 \li LONG VARCHAR
62 \li Not null-terminated varying length character string
63 \li Mapped to QString
64 \row
65 \li BLOB
66 \li Not null-terminated varying binary string with 4-byte string
67 length indicator
68 \li Mapped to QByteArray
69 \row
70 \li CLOB
71 \li Character large string object
72 \li Mapped to QString
73 \row
74 \li DATE
75 \li Null-terminated character string of the following format:
76 yyyy-mm-dd
77 \li Mapped to QDate
78 \row
79 \li TIME
80 \li Null-terminated character string of the following format: hh.mm.ss
81 \li Mapped to QTime
82 \row
83 \li TIMESTAMP
84 \li Null-terminated character string of the following format: yyyy-mm-dd-hh.mm.ss.nnnnnn
85 \li Mapped to QDateTime
86 \endtable
87
88 \section2 Borland InterBase Data Types
89
90 \table 90%
91 \header
92 \li Borland InterBase data type
93 \li SQL type description
94 \li Recommended input (C++ or Qt data type)
95 \row
96 \li BOOLEAN
97 \li Boolean
98 \li bool
99 \row
100 \li TINYINT
101 \li 8 bit signed integer
102 \li typedef qint8
103 \row
104 \li SMALLINT
105 \li 16-bit signed integer
106 \li typedef qint16
107 \row
108 \li INTEGER
109 \li 32-bit signed integer
110 \li typedef qint32
111 \row
112 \li BIGINT LONG
113 \li 64-bit signed integer
114 \li typedef qint64
115 \row
116 \li REAL FLOAT
117 \li 32-bit floating point
118 \li typedef qreal
119 \row
120 \li FLOAT
121 \li 64-bit floating point
122 \li typedef qreal
123 \row
124 \li DOUBLE
125 \li 64-bit floating point
126 \li typedef qreal
127 \row
128 \li DOUBLE PRECISION
129 \li 64-bit Double-precision floating point
130 \li Mapped to QString for high precision doubles, otherwise qreal
131 \row
132 \li VARCHAR STRING
133 \li Character string, Unicode
134 \li Mapped to QString
135 \row
136 \li CLOB
137 \li Character large string object
138 \li Mapped to QString
139 \row
140 \li DATE
141 \li Displays date. Format: 'yyyy-mm-dd'
142 \li Mapped to QDate
143 \row
144 \li TIME
145 \li Displays time. Format is 'hh:mm:ss' in 24-hour format
146 \li Mapped to QTime
147 \row
148 \li TIMESTAMP
149 \li Displays a timestamp. Format is 'yyyy-mm-dd hh:mm:ss'
150 \li Mapped to QDateTime
151 \endtable
152
153 \section2 MySQL Data Types
154
155 \table 90%
156 \header
157 \li MySQL data type
158 \li SQL type description
159 \li Recommended input (C++ or Qt data type)
160 \row
161 \li TINYINT
162 \li 8 bit signed integer
163 \li typedef qint8
164 \row
165 \li TINYINT UNSIGNED
166 \li 8 bit unsigned integer
167 \li typedef quint8
168 \row
169 \li SMALLINT
170 \li 16-bit signed integer
171 \li typedef qint16
172 \row
173 \li SMALLINT UNSIGNED
174 \li 16-bit unsigned integer
175 \li typedef quint16
176 \row
177 \li INT
178 \li 32-bit signed integer
179 \li typedef qint32
180 \row
181 \li INT UNSIGNED
182 \li 32-bit unsigned integer
183 \li typedef quint32
184 \row
185 \li BIGINT
186 \li 64-bit signed integer
187 \li typedef qint64
188 \row
189 \li FLOAT
190 \li 32-bit Floating Point
191 \li typedef qreal
192 \row
193 \li DOUBLE
194 \li 64-bit Floating Point
195 \li Mapped to QString for high precision doubles, otherwise qreal
196 \row
197 \li CHAR
198 \li Character string
199 \li Mapped to QString
200 \row
201 \li VARCHAR
202 \li Character string
203 \li Mapped to QString
204 \row
205 \li TINYTEXT
206 \li Character string
207 \li Mapped to QString
208 \row
209 \li TEXT
210 \li Character string
211 \li Mapped to QString
212 \row
213 \li MEDIUMTEXT
214 \li Character string
215 \li Mapped to QString
216 \row
217 \li LONGTEXT
218 \li Character string
219 \li Mapped to QString
220 \row
221 \li CLOB
222 \li Character large string object
223 \li Mapped to QString
224 \row
225 \li all BLOB types
226 \li BLOB
227 \li Mapped to QByteArray
228 \row
229 \li DATE
230 \li Date without Time
231 \li Mapped to QDate
232 \row
233 \li DATETIME
234 \li Date and Time
235 \li Mapped to QDateTime
236 \row
237 \li TIMESTAMP
238 \li Date and Time
239 \li Mapped to QDateTime
240 \row
241 \li TIME
242 \li Time
243 \li Mapped to QTime
244 \row
245 \li YEAR
246 \li Year (int)
247 \li Mapped to QDateTime
248 \row
249 \li ENUM
250 \li Enumeration of Value Set
251 \li Mapped to QString
252 \endtable
253
254 \section2 Oracle Call Interface Data Types
255
256 \table 90%
257 \header
258 \li Oracle Call Interface data type
259 \li SQL type description
260 \li Recommended input (C++ or Qt data type)
261 \row
262 \li NUMBER
263 \li FLOAT, DOUBLE, PRECISIONc REAL
264 \li Mapped to QString for high precision doubles, otherwise qreal
265 \row
266 \li NUMBER(38)
267 \li INTEGER INT SMALLINT
268 \li typedef qint8/16/32/64
269 \row
270 \li NUMBER(p,s)
271 \li NUMERIC(p,s) DECIMAL(p,s)a
272 \li Mapped to QString
273 \row
274 \li NVARCHAR2(n)
275 \li Character string (NATIONAL CHARACTER VARYING(n) NATIONAL
276 CHAR VARYING(n) NCHAR VARYING(n))
277 \li Mapped to QString
278 \row
279 \li NCHAR(n)
280 \li Character string (NATIONAL CHARACTER(n) NATIONAL CHAR(n)
281 NCHAR(n))
282 \li Mapped to QString
283 \row
284 \li CHAR(n)
285 \li Character string (CHARACTER(n) CHAR(n))
286 \li Mapped to QString
287 \row
288 \li CLOB
289 \li Character large string object
290 \li Mapped to QString
291 \row
292 \li BLOB
293 \li A binary large object
294 \li Mapped to QByteArray
295 \row
296 \li TIMESTAMP
297 \li Year, month, and day values of date, as well as hour, minute,
298 and second values of time
299 \li Mapped to QDateTime
300 \endtable
301
302 \section2 ODBC Data Types
303
304 \table 90%
305 \header
306 \li ODBC data type
307 \li SQL type description
308 \li Recommended input (C++ or Qt data type)
309 \row
310 \li BIT
311 \li Boolean
312 \li BOOL
313 \row
314 \li TINYINT
315 \li 8 bit integer
316 \li typedef qint8
317 \row
318 \li SMALLINT
319 \li 16-bit signed integer
320 \li typedef qint16
321 \row
322 \li INTEGER
323 \li 32-bit signed integer
324 \li typedef qint32
325 \row
326 \li BIGINT
327 \li 64-bit signed integer
328 \li typedef qint64
329 \row
330 \li REAL
331 \li 32-bit Single-precision floating point
332 \li typedef qreal
333 \row
334 \li FLOAT
335 \li 64-bit Double floating point
336 \li typedef qreal
337 \row
338 \li DOUBLE
339 \li 64-bit Double floating point
340 \li Mapped to QString for high precision doubles, otherwise qreal
341 \row
342 \li CHAR
343 \li Character string
344 \li Mapped to QString
345 \row
346 \li VARCHAR
347 \li Character string
348 \li Mapped to QString
349 \row
350 \li LONGVARCHAR
351 \li Character string
352 \li Mapped to QString
353 \row
354 \li CLOB
355 \li Character large string object
356 \li Mapped to QString
357 \row
358 \li DATE
359 \li Character string
360 \li Mapped to QDate
361 \row
362 \li TIME
363 \li Character Time, Character string
364 \li Mapped to QTime
365 \row
366 \li TIMESTAMP
367 \li Character Time, Character string
368 \li Mapped to QDateTime
369 \endtable
370
371 \section2 PostgreSQL Data Types
372
373 \table 90%
374 \header
375 \li PostgreSQL data type
376 \li SQL type description
377 \li Recommended input (C++ or Qt data type)
378 \row
379 \li BOOLEAN
380 \li Boolean
381 \li bool
382 \row
383 \li SMALLINT
384 \li 16-bit signed integer
385 \li typedef qint16
386 \row
387 \li INTEGER
388 \li 32-bit signed integer
389 \li typedef qint32
390 \row
391 \li BIGINT
392 \li 64-bit signed integer
393 \li typedef qint64
394 \row
395 \li REAL
396 \li 32-bit variable-precision floating point
397 \li typedef qreal
398 \row
399 \li DOUBLE PRECISION
400 \li 64-bit variable-precision floating point
401 \li Mapped to QString for high precision doubles, otherwise qreal
402 \row
403 \li DECIMAL VARIABLE
404 \li user-specified precision, exact
405 \li typedef qreal
406 \row
407 \li NUMERIC VARIABLE
408 \li user-specified precision, exact
409 \li typedef qreal
410 \row
411 \li VARCHAR
412 \li variable-length character string
413 \li Mapped to QString
414 \row
415 \li CHARACTER
416 \li Character string of fixed-length
417 \li Mapped to QString
418 \row
419 \li TEXT
420 \li Character string of variable-length
421 \li Mapped to QString
422 \row
423 \li CLOB
424 \li Character large string object
425 \li Mapped to QString
426 \row
427 \li TIMESTAMP
428 \li 8 bytes, both date and time
429 \li Mapped to QDateTime
430 \row
431 \li TIMESTAMP
432 \li 8 bytes, both date and time, with time zone
433 \li Mapped to QDateTime
434 \row
435 \li DATE
436 \li 4 bytes, dates only
437 \li Mapped to QDate
438 \row
439 \li TIME
440 \li 8 bytes, times of day only 00:00:00.00 - 23:59:59.99
441 \li Mapped to QTime
442 \row
443 \li TIME
444 \li 12 bytes times of day only, with time zone 00:00:00.00+12
445 \li Mapped to QDateTime
446 \endtable
447
448 \section2 QSQLITE SQLite version 3 Data Types
449
450 \table 90%
451 \header
452 \li QSQLITE SQLite version 3 data type
453 \li SQL type description
454 \li Recommended input (C++ or Qt data type)
455 \row
456 \li NULL
457 \li NULL value.
458 \li NULL
459 \row
460 \li INTEGER
461 \li Signed integer, stored in 8, 16, 24, 32, 48, or 64-bits
462 depending on the magnitude of the value.
463 \li typedef qint8/16/32/64
464 \row
465 \li REAL
466 \li 64-bit floating point value.
467 \li typedef qreal
468 \row
469 \li TEXT
470 \li Character string (UTF-8, UTF-16BE or UTF-16-LE).
471 \li Mapped to QString
472 \row
473 \li CLOB
474 \li Character large string object
475 \li Mapped to QString
476 \row
477 \li BLOB
478 \li The value is a BLOB of data, stored exactly as it was input.
479 \li Mapped to QByteArray
480 \endtable
481
482 \section2 Mimer SQL Data Types
483
484 \table 90%
485 \header
486 \li Mimer SQL type
487 \li SQL type description
488 \li Recommended input (C++ or Qt data type)
489 \row
490 \li SMALLINT
491 \li 16-bit signed integer
492 \li typedef qint16
493 \row
494 \li INTEGER
495 \li 32-bit signed integer
496 \li typedef qint32
497 \row
498 \li BIGINT
499 \li 64-bit signed integer
500 \li typedef qint64
501 \row
502 \li REAL
503 \li 32-bit Single-precision floating point
504 \li typedef qreal
505 \row
506 \li DOUBLE PRECISION
507 \li 64-bit Double-precision floating point
508 \li Mapped to QString for high precision doubles, otherwise qreal
509 \row
510 \li FLOAT
511 \li 64-bit Double-precision floating point
512 \li typedef qreal
513 \row
514 \li CHAR
515 \li Fixed-length, null-terminated character string
516 \li Mapped to QString
517 \row
518 \li VARCHAR
519 \li Null-terminated varying length string
520 \li Mapped to QString
521 \row
522 \li NCHAR
523 \li Fixed-length, null-terminated Unicode character string
524 \li Mapped to QString
525 \row
526 \li NVARCHAR
527 \li Null-terminated varying length Unicode string
528 \li Mapped to QString
529 \row
530 \li BLOB
531 \li Not null-terminated varying binary string with 4-byte string
532 length indicator
533 \li Mapped to QByteArray
534 \row
535 \li CLOB
536 \li Character large string object
537 \li Mapped to QString
538 \row
539 \li NCLOB
540 \li National Character large string object
541 \li Mapped to QString
542 \row
543 \li DATE
544 \li Null-terminated character string of the following format:
545 yyyy-mm-dd
546 \li Mapped to QDate
547 \row
548 \li TIME
549 \li Null-terminated character string of the following format: hh.mm.ss
550 \li Mapped to QTime
551 \row
552 \li TIMESTAMP
553 \li Null-terminated character string of the following format: yyyy-mm-dd-hh.mm.ss.nnnnnn
554 \li Mapped to QDateTime
555 \row
556 \li BUILTIN.UUID
557 \li Universally unique identifier
558 \li Mapped to QUuid
559 \row
560 \li BOOLEAN
561 \li Boolean
562 \li bool
563 \row
564 \li DECIMAL(p,s)
565 \li By default mapping to QString
566 \endtable
567*/