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