Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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 \section2 IBM DB2 Data Types
20
21 \table 90%
22 \header
23 \li IBM DB2 data type
24 \li SQL type description
25 \li Recommended input (C++ or Qt data type)
26 \row
27 \li SMALLINT
28 \li 16-bit signed integer
29 \li typedef qint16
30 \row
31 \li INTEGER
32 \li 32-bit signed integer
33 \li typedef qint32
34 \row
35 \li BIGINT
36 \li 64-bit signed integer
37 \li typedef qint64
38 \row
39 \li REAL
40 \li 32-bit Single-precision floating point
41 \li typedef qreal
42 \row
43 \li DOUBLE PRECISION
44 \li 64-bit Double-precision floating point
45 \li Mapped to QString for high precision doubles, otherwise qreal
46 \row
47 \li FLOAT
48 \li 64-bit Double-precision floating point
49 \li typedef qreal
50 \row
51 \li CHAR
52 \li Fixed-length, null-terminated character string
53 \li Mapped to QString
54 \row
55 \li VARCHAR
56 \li Null-terminated varying length string
57 \li Mapped to QString
58 \row
59 \li LONG VARCHAR
60 \li Not null-terminated varying length character string
61 \li Mapped to QString
62 \row
63 \li BLOB
64 \li Not null-terminated varying binary string with 4-byte string
65 length indicator
66 \li Mapped to QByteArray
67 \row
68 \li CLOB
69 \li Character large string object
70 \li Mapped to QString
71 \row
72 \li DATE
73 \li Null-terminated character string of the following format:
74 yyyy-mm-dd
75 \li Mapped to QDate
76 \row
77 \li TIME
78 \li Null-terminated character string of the following format: hh.mm.ss
79 \li Mapped to QTime
80 \row
81 \li TIMESTAMP
82 \li Null-terminated character string of the following format: yyyy-mm-dd-hh.mm.ss.nnnnnn
83 \li Mapped to QDateTime
84 \endtable
85
86 \section2 Borland InterBase Data Types
87
88 \table 90%
89 \header
90 \li Borland InterBase data type
91 \li SQL type description
92 \li Recommended input (C++ or Qt data type)
93 \row
94 \li BOOLEAN
95 \li Boolean
96 \li bool
97 \row
98 \li TINYINT
99 \li 8 bit signed integer
100 \li typedef qint8
101 \row
102 \li SMALLINT
103 \li 16-bit signed integer
104 \li typedef qint16
105 \row
106 \li INTEGER
107 \li 32-bit signed integer
108 \li typedef qint32
109 \row
110 \li BIGINT LONG
111 \li 64-bit signed integer
112 \li typedef qint64
113 \row
114 \li REAL FLOAT
115 \li 32-bit floating point
116 \li typedef qreal
117 \row
118 \li FLOAT
119 \li 64-bit floating point
120 \li typedef qreal
121 \row
122 \li DOUBLE
123 \li 64-bit floating point
124 \li typedef qreal
125 \row
126 \li DOUBLE PRECISION
127 \li 64-bit Double-precision floating point
128 \li Mapped to QString for high precision doubles, otherwise qreal
129 \row
130 \li VARCHAR STRING
131 \li Character string, Unicode
132 \li Mapped to QString
133 \row
134 \li CLOB
135 \li Character large string object
136 \li Mapped to QString
137 \row
138 \li DATE
139 \li Displays date. Format: 'yyyy-mm-dd'
140 \li Mapped to QDate
141 \row
142 \li TIME
143 \li Displays time. Format is 'hh:mm:ss' in 24-hour format
144 \li Mapped to QTime
145 \row
146 \li TIMESTAMP
147 \li Displays a timestamp. Format is 'yyyy-mm-dd hh:mm:ss'
148 \li Mapped to QDateTime
149 \endtable
150
151 \section2 MySQL Data Types
152
153 \table 90%
154 \header
155 \li MySQL data type
156 \li SQL type description
157 \li Recommended input (C++ or Qt data type)
158 \row
159 \li TINYINT
160 \li 8 bit signed integer
161 \li typedef qint8
162 \row
163 \li TINYINT UNSIGNED
164 \li 8 bit unsigned integer
165 \li typedef quint8
166 \row
167 \li SMALLINT
168 \li 16-bit signed integer
169 \li typedef qint16
170 \row
171 \li SMALLINT UNSIGNED
172 \li 16-bit unsigned integer
173 \li typedef quint16
174 \row
175 \li INT
176 \li 32-bit signed integer
177 \li typedef qint32
178 \row
179 \li INT UNSIGNED
180 \li 32-bit unsigned integer
181 \li typedef quint32
182 \row
183 \li BIGINT
184 \li 64-bit signed integer
185 \li typedef qint64
186 \row
187 \li FLOAT
188 \li 32-bit Floating Point
189 \li typedef qreal
190 \row
191 \li DOUBLE
192 \li 64-bit Floating Point
193 \li Mapped to QString for high precision doubles, otherwise qreal
194 \row
195 \li CHAR
196 \li Character string
197 \li Mapped to QString
198 \row
199 \li VARCHAR
200 \li Character string
201 \li Mapped to QString
202 \row
203 \li TINYTEXT
204 \li Character string
205 \li Mapped to QString
206 \row
207 \li TEXT
208 \li Character string
209 \li Mapped to QString
210 \row
211 \li MEDIUMTEXT
212 \li Character string
213 \li Mapped to QString
214 \row
215 \li LONGTEXT
216 \li Character string
217 \li Mapped to QString
218 \row
219 \li CLOB
220 \li Character large string object
221 \li Mapped to QString
222 \row
223 \li all BLOB types
224 \li BLOB
225 \li Mapped to QByteArray
226 \row
227 \li DATE
228 \li Date without Time
229 \li Mapped to QDate
230 \row
231 \li DATETIME
232 \li Date and Time
233 \li Mapped to QDateTime
234 \row
235 \li TIMESTAMP
236 \li Date and Time
237 \li Mapped to QDateTime
238 \row
239 \li TIME
240 \li Time
241 \li Mapped to QTime
242 \row
243 \li YEAR
244 \li Year (int)
245 \li Mapped to QDateTime
246 \row
247 \li ENUM
248 \li Enumeration of Value Set
249 \li Mapped to QString
250 \endtable
251
252 \section2 Oracle Call Interface Data Types
253
254 \table 90%
255 \header
256 \li Oracle Call Interface data type
257 \li SQL type description
258 \li Recommended input (C++ or Qt data type)
259 \row
260 \li NUMBER
261 \li FLOAT, DOUBLE, PRECISIONc REAL
262 \li Mapped to QString for high precision doubles, otherwise qreal
263 \row
264 \li NUMBER(38)
265 \li INTEGER INT SMALLINT
266 \li typedef qint8/16/32/64
267 \row
268 \li NUMBER(p,s)
269 \li NUMERIC(p,s) DECIMAL(p,s)a
270 \li Mapped to QString
271 \row
272 \li NVARCHAR2(n)
273 \li Character string (NATIONAL CHARACTER VARYING(n) NATIONAL
274 CHAR VARYING(n) NCHAR VARYING(n))
275 \li Mapped to QString
276 \row
277 \li NCHAR(n)
278 \li Character string (NATIONAL CHARACTER(n) NATIONAL CHAR(n)
279 NCHAR(n))
280 \li Mapped to QString
281 \row
282 \li CHAR(n)
283 \li Character string (CHARACTER(n) CHAR(n))
284 \li Mapped to QString
285 \row
286 \li CLOB
287 \li Character large string object
288 \li Mapped to QString
289 \row
290 \li BLOB
291 \li A binary large object
292 \li Mapped to QByteArray
293 \row
294 \li TIMESTAMP
295 \li Year, month, and day values of date, as well as hour, minute,
296 and second values of time
297 \li Mapped to QDateTime
298 \endtable
299
300 \section2 ODBC Data Types
301
302 \table 90%
303 \header
304 \li ODBC data type
305 \li SQL type description
306 \li Recommended input (C++ or Qt data type)
307 \row
308 \li BIT
309 \li Boolean
310 \li BOOL
311 \row
312 \li TINYINT
313 \li 8 bit integer
314 \li typedef qint8
315 \row
316 \li SMALLINT
317 \li 16-bit signed integer
318 \li typedef qint16
319 \row
320 \li INTEGER
321 \li 32-bit signed integer
322 \li typedef qint32
323 \row
324 \li BIGINT
325 \li 64-bit signed integer
326 \li typedef qint64
327 \row
328 \li REAL
329 \li 32-bit Single-precision floating point
330 \li typedef qreal
331 \row
332 \li FLOAT
333 \li 64-bit Double floating point
334 \li typedef qreal
335 \row
336 \li DOUBLE
337 \li 64-bit Double floating point
338 \li Mapped to QString for high precision doubles, otherwise qreal
339 \row
340 \li CHAR
341 \li Character string
342 \li Mapped to QString
343 \row
344 \li VARCHAR
345 \li Character string
346 \li Mapped to QString
347 \row
348 \li LONGVARCHAR
349 \li Character string
350 \li Mapped to QString
351 \row
352 \li CLOB
353 \li Character large string object
354 \li Mapped to QString
355 \row
356 \li DATE
357 \li Character string
358 \li Mapped to QDate
359 \row
360 \li TIME
361 \li Character Time, Character string
362 \li Mapped to QTime
363 \row
364 \li TIMESTAMP
365 \li Character Time, Character string
366 \li Mapped to QDateTime
367 \endtable
368
369 \section2 PostgreSQL Data Types
370
371 \table 90%
372 \header
373 \li PostgreSQL data type
374 \li SQL type description
375 \li Recommended input (C++ or Qt data type)
376 \row
377 \li BOOLEAN
378 \li Boolean
379 \li bool
380 \row
381 \li SMALLINT
382 \li 16-bit signed integer
383 \li typedef qint16
384 \row
385 \li INTEGER
386 \li 32-bit signed integer
387 \li typedef qint32
388 \row
389 \li BIGINT
390 \li 64-bit signed integer
391 \li typedef qint64
392 \row
393 \li REAL
394 \li 32-bit variable-precision floating point
395 \li typedef qreal
396 \row
397 \li DOUBLE PRECISION
398 \li 64-bit variable-precision floating point
399 \li Mapped to QString for high precision doubles, otherwise qreal
400 \row
401 \li DECIMAL VARIABLE
402 \li user-specified precision, exact
403 \li typedef qreal
404 \row
405 \li NUMERIC VARIABLE
406 \li user-specified precision, exact
407 \li typedef qreal
408 \row
409 \li VARCHAR
410 \li variable-length character string
411 \li Mapped to QString
412 \row
413 \li CHARACTER
414 \li Character string of fixed-length
415 \li Mapped to QString
416 \row
417 \li TEXT
418 \li Character string of variable-length
419 \li Mapped to QString
420 \row
421 \li CLOB
422 \li Character large string object
423 \li Mapped to QString
424 \row
425 \li TIMESTAMP
426 \li 8 bytes, both date and time
427 \li Mapped to QDateTime
428 \row
429 \li TIMESTAMP
430 \li 8 bytes, both date and time, with time zone
431 \li Mapped to QDateTime
432 \row
433 \li DATE
434 \li 4 bytes, dates only
435 \li Mapped to QDate
436 \row
437 \li TIME
438 \li 8 bytes, times of day only 00:00:00.00 - 23:59:59.99
439 \li Mapped to QTime
440 \row
441 \li TIME
442 \li 12 bytes times of day only, with time zone 00:00:00.00+12
443 \li Mapped to QDateTime
444 \endtable
445
446 \section2 QSQLITE SQLite version 3 Data Types
447
448 \table 90%
449 \header
450 \li QSQLITE SQLite version 3 data type
451 \li SQL type description
452 \li Recommended input (C++ or Qt data type)
453 \row
454 \li NULL
455 \li NULL value.
456 \li NULL
457 \row
458 \li INTEGER
459 \li Signed integer, stored in 8, 16, 24, 32, 48, or 64-bits
460 depending on the magnitude of the value.
461 \li typedef qint8/16/32/64
462 \row
463 \li REAL
464 \li 64-bit floating point value.
465 \li typedef qreal
466 \row
467 \li TEXT
468 \li Character string (UTF-8, UTF-16BE or UTF-16-LE).
469 \li Mapped to QString
470 \row
471 \li CLOB
472 \li Character large string object
473 \li Mapped to QString
474 \row
475 \li BLOB
476 \li The value is a BLOB of data, stored exactly as it was input.
477 \li Mapped to QByteArray
478 \endtable
479
480 \section2 Mimer SQL Data Types
481
482 \table 90%
483 \header
484 \li Mimer SQL type
485 \li SQL type description
486 \li Recommended input (C++ or Qt data type)
487 \row
488 \li SMALLINT
489 \li 16-bit signed integer
490 \li typedef qint16
491 \row
492 \li INTEGER
493 \li 32-bit signed integer
494 \li typedef qint32
495 \row
496 \li INTEGER(n)
497 \li Integer with up to 45 digits precision
498 \li Mapped to QString
499 \row
500 \li BIGINT
501 \li 64-bit signed integer
502 \li typedef qint64
503 \row
504 \li REAL
505 \li 32-bit Single-precision IEEE floating point
506 \li typedef float
507 \row
508 \li DOUBLE PRECISION
509 \li 64-bit Double-precision IEEE floating point
510 \li Mapped to QString for high precision doubles, otherwise qreal
511 \row
512 \li FLOAT
513 \li 64-bit Double-precision IEEE floating point
514 \li Mapped to QString for high precision doubles, otherwise qreal
515 \row
516 \li FLOAT(n)
517 \li Floating point with up to 45 digits precision
518 \li Mapped to QString
519 \row
520 \li DECIMAL(p,s)
521 \li Decimal with up to 45 digits precision and scale
522 \li Mapped to QString
523 \row
524 \li CHAR
525 \li Fixed-length character Latin-1 string (CHAR or character)
526 \li Mapped to QString
527 \row
528 \li VARCHAR
529 \li Variable length Latin-1 string (VARCHAR or CHARACTER VARYING)
530 \li Mapped to QString
531 \row
532 \li NCHAR
533 \li Fixed-length Unicode string (NCHAR or NATIONAL CHARACTER)
534 \li Mapped to QString
535 \row
536 \li NVARCHAR
537 \li Variable length Unicode string (NVARCHAR or NATIONAL CHARACTER VARYING)
538 \li Mapped to QString
539 \row
540 \li BINARY
541 \li Fixed length binary data
542 \li Mapped to QByteArray
543 \row
544 \li VARBINARY
545 \li Variable length binary data (VARBINARY or BINARY VARYING)
546 \li Mapped to QByteArray
547 \row
548 \li BLOB
549 \li Binary large object (BLOB or BINARY LARGE OBJECT)
550 \li Mapped to QByteArray
551 \row
552 \li CLOB
553 \li Latin-1 character large object (CLOB or CHARACTER LARGE OBJECT)
554 \li Mapped to QString
555 \row
556 \li NCLOB
557 \li Unicode character large object (NCLOB or NATIONAL CHARACTER LARGE OBJECT)
558 \li Mapped to QString
559 \row
560 \li DATE
561 \li Date consisting of year, month, and day
562 \li Mapped to QDate
563 \row
564 \li TIME
565 \li Time consisting of hours, minute, seconds with optional fractional seconds
566 \li Mapped to QTime
567 \row
568 \li TIMESTAMP
569 \li Date and time with optional fractional seconds
570 \li Mapped to QDateTime
571 \row
572 \li BUILTIN.UUID
573 \li Universally unique identifier
574 \li Mapped to QUuid
575 \row
576 \li BOOLEAN
577 \li Boolean
578 \li bool
579 \row
580 \li INTERVAL YEAR(7)
581 \li Year, format '±yyyyyyy' (max precision)
582 \li Mapped to QString
583 \row
584 \li INTERVAL YEAR(7) TO MONTH
585 \li Year to month, format '±yyyyyyy-mm' (max precision)
586 \li Mapped to QString
587 \row
588 \li INTERVAL MONTH(7)
589 \li Month, format '±mmmmmmm' (max precision)
590 \li Mapped to QString
591 \row
592 \li INTERVAL DAY(7)
593 \li Day, format '±ddddddd' (max precision)
594 \li Mapped to QString
595 \row
596 \li INTERVAL DAY(7) TO HOUR
597 \li Day to hour, format '±ddddddd hh' (max precision)
598 \li Mapped to QString
599 \row
600 \li INTERVAL DAY(7) TO MINUTE
601 \li Day to minute, format '±ddddddd hh:mm' (max precision)
602 \li Mapped to QString
603 \row
604 \li INTERVAL DAY(7) TO SECOND(9)
605 \li Day to second, format '±ddddddd hh:mm:ss[.fffffffff]' (max precision)
606 \li Mapped to QString
607 \row
608 \li INTERVAL HOUR(8)
609 \li Hour, format '±hhhhhhhh' (max precision)
610 \li Mapped to QString
611 \row
612 \li INTERVAL HOUR(8) TO MINUTE
613 \li Hour to minute, format '±hhhhhhhh:mm' (max precision)
614 \li Mapped to QString
615 \row
616 \li INTERVAL HOUR(8) TO SECOND(9)
617 \li Hour to second, format '±hhhhhhhh:mm:ss[.fffffffff]' (max precision)
618 \li Mapped to QString
619 \row
620 \li INTERVAL MINUTE(10)
621 \li Minute, format '±mmmmmmmmmm' (max precision)
622 \li Mapped to QString
623 \row
624 \li INTERVAL MINUTE(10) TO SECOND(9)
625 \li Minute to second, format '±mmmmmmmmmm:ss[.fffffffff]' (max precision)
626 \li Mapped to QString
627 \row
628 \li INTERVAL SECOND(12,9)
629 \li Second, format '±ssssssssssss[.fffffffff]' (max precision)
630 \li Mapped to QString
631 \endtable
632*/