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