Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
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 INTEGER(n)
499 \li Integer with up to 45 digits precision
500 \li Mapped to QString
501 \row
502 \li BIGINT
503 \li 64-bit signed integer
504 \li typedef qint64
505 \row
506 \li REAL
507 \li 32-bit Single-precision IEEE floating point
508 \li typedef float
509 \row
510 \li DOUBLE PRECISION
511 \li 64-bit Double-precision IEEE floating point
512 \li Mapped to QString for high precision doubles, otherwise qreal
513 \row
514 \li FLOAT
515 \li 64-bit Double-precision IEEE floating point
516 \li Mapped to QString for high precision doubles, otherwise qreal
517 \row
518 \li FLOAT(n)
519 \li Floating point with up to 45 digits precision
520 \li Mapped to QString
521 \row
522 \li DECIMAL(p,s)
523 \li Decimal with up to 45 digits precision and scale
524 \li Mapped to QString
525 \row
526 \li CHAR
527 \li Fixed-length character Latin-1 string (CHAR or character)
528 \li Mapped to QString
529 \row
530 \li VARCHAR
531 \li Variable length Latin-1 string (VARCHAR or CHARACTER VARYING)
532 \li Mapped to QString
533 \row
534 \li NCHAR
535 \li Fixed-length Unicode string (NCHAR or NATIONAL CHARACTER)
536 \li Mapped to QString
537 \row
538 \li NVARCHAR
539 \li Variable length Unicode string (NVARCHAR or NATIONAL CHARACTER VARYING)
540 \li Mapped to QString
541 \row
542 \li BINARY
543 \li Fixed length binary data
544 \li Mapped to QByteArray
545 \row
546 \li VARBINARY
547 \li Variable length binary data (VARBINARY or BINARY VARYING)
548 \li Mapped to QByteArray
549 \row
550 \li BLOB
551 \li Binary large object (BLOB or BINARY LARGE OBJECT)
552 \li Mapped to QByteArray
553 \row
554 \li CLOB
555 \li Latin-1 character large object (CLOB or CHARACTER LARGE OBJECT)
556 \li Mapped to QString
557 \row
558 \li NCLOB
559 \li Unicode character large object (NCLOB or NATIONAL CHARACTER LARGE OBJECT)
560 \li Mapped to QString
561 \row
562 \li DATE
563 \li Date consisting of year, month, and day
564 \li Mapped to QDate
565 \row
566 \li TIME
567 \li Time consisting of hours, minute, seconds with optional fractional seconds
568 \li Mapped to QTime
569 \row
570 \li TIMESTAMP
571 \li Date and time with optional fractional seconds
572 \li Mapped to QDateTime
573 \row
574 \li BUILTIN.UUID
575 \li Universally unique identifier
576 \li Mapped to QUuid
577 \row
578 \li BOOLEAN
579 \li Boolean
580 \li bool
581 \row
582 \li INTERVAL YEAR(7)
583 \li Year, format '±yyyyyyy' (max precision)
584 \li Mapped to QString
585 \row
586 \li INTERVAL YEAR(7) TO MONTH
587 \li Year to month, format '±yyyyyyy-mm' (max precision)
588 \li Mapped to QString
589 \row
590 \li INTERVAL MONTH(7)
591 \li Month, format '±mmmmmmm' (max precision)
592 \li Mapped to QString
593 \row
594 \li INTERVAL DAY(7)
595 \li Day, format '±ddddddd' (max precision)
596 \li Mapped to QString
597 \row
598 \li INTERVAL DAY(7) TO HOUR
599 \li Day to hour, format '±ddddddd hh' (max precision)
600 \li Mapped to QString
601 \row
602 \li INTERVAL DAY(7) TO MINUTE
603 \li Day to minute, format '±ddddddd hh:mm' (max precision)
604 \li Mapped to QString
605 \row
606 \li INTERVAL DAY(7) TO SECOND(9)
607 \li Day to second, format '±ddddddd hh:mm:ss[.fffffffff]' (max precision)
608 \li Mapped to QString
609 \row
610 \li INTERVAL HOUR(8)
611 \li Hour, format '±hhhhhhhh' (max precision)
612 \li Mapped to QString
613 \row
614 \li INTERVAL HOUR(8) TO MINUTE
615 \li Hour to minute, format '±hhhhhhhh:mm' (max precision)
616 \li Mapped to QString
617 \row
618 \li INTERVAL HOUR(8) TO SECOND(9)
619 \li Hour to second, format '±hhhhhhhh:mm:ss[.fffffffff]' (max precision)
620 \li Mapped to QString
621 \row
622 \li INTERVAL MINUTE(10)
623 \li Minute, format '±mmmmmmmmmm' (max precision)
624 \li Mapped to QString
625 \row
626 \li INTERVAL MINUTE(10) TO SECOND(9)
627 \li Minute to second, format '±mmmmmmmmmm:ss[.fffffffff]' (max precision)
628 \li Mapped to QString
629 \row
630 \li INTERVAL SECOND(12,9)
631 \li Second, format '±ssssssssssss[.fffffffff]' (max precision)
632 \li Mapped to QString
633 \endtable
634*/