~ubuntu-branches/ubuntu/precise/libdbi-drivers/precise

« back to all changes in this revision

Viewing changes to drivers/sqlite/dbd_sqlite/x122.html

  • Committer: Bazaar Package Importer
  • Author(s): David Parker
  • Date: 2004-02-01 14:33:06 UTC
  • Revision ID: james.westby@ubuntu.com-20040201143306-pmwubrx4d4jrq7om
Tags: upstream-0.7.1
ImportĀ upstreamĀ versionĀ 0.7.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
2
<HTML
 
3
><HEAD
 
4
><TITLE
 
5
>SQLite (mis)features</TITLE
 
6
><META
 
7
NAME="GENERATOR"
 
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
 
9
REL="HOME"
 
10
TITLE="sqlite driver manual"
 
11
HREF="index.html"><LINK
 
12
REL="UP"
 
13
TITLE="Peculiarities you should know about"
 
14
HREF="c119.html"><LINK
 
15
REL="PREVIOUS"
 
16
TITLE="Peculiarities you should know about"
 
17
HREF="c119.html"><LINK
 
18
REL="NEXT"
 
19
TITLE="sqlite driver misfeatures"
 
20
HREF="x198.html"></HEAD
 
21
><BODY
 
22
CLASS="SECT1"
 
23
BGCOLOR="#FFFFFF"
 
24
TEXT="#000000"
 
25
LINK="#0000FF"
 
26
VLINK="#840084"
 
27
ALINK="#0000FF"
 
28
><DIV
 
29
CLASS="NAVHEADER"
 
30
><TABLE
 
31
SUMMARY="Header navigation table"
 
32
WIDTH="100%"
 
33
BORDER="0"
 
34
CELLPADDING="0"
 
35
CELLSPACING="0"
 
36
><TR
 
37
><TH
 
38
COLSPAN="3"
 
39
ALIGN="center"
 
40
>sqlite driver manual: A libdbi driver using the SQLite embedded database engine</TH
 
41
></TR
 
42
><TR
 
43
><TD
 
44
WIDTH="10%"
 
45
ALIGN="left"
 
46
VALIGN="bottom"
 
47
><A
 
48
HREF="c119.html"
 
49
ACCESSKEY="P"
 
50
>Prev</A
 
51
></TD
 
52
><TD
 
53
WIDTH="80%"
 
54
ALIGN="center"
 
55
VALIGN="bottom"
 
56
>Chapter 4. Peculiarities you should know about</TD
 
57
><TD
 
58
WIDTH="10%"
 
59
ALIGN="right"
 
60
VALIGN="bottom"
 
61
><A
 
62
HREF="x198.html"
 
63
ACCESSKEY="N"
 
64
>Next</A
 
65
></TD
 
66
></TR
 
67
></TABLE
 
68
><HR
 
69
ALIGN="LEFT"
 
70
WIDTH="100%"></DIV
 
71
><DIV
 
72
CLASS="SECT1"
 
73
><H1
 
74
CLASS="SECT1"
 
75
><A
 
76
NAME="AEN122"
 
77
>4.1. SQLite (mis)features</A
 
78
></H1
 
79
><P
 
80
>As the SQLite package is constantly being improved, you should refer to the original documentation about the SQL features it <A
 
81
HREF="http://www.sqlite.org/lang.html"
 
82
TARGET="_top"
 
83
>supports</A
 
84
> and about the SQL features it <A
 
85
HREF="http://www.sqlite.org/omitted.html"
 
86
TARGET="_top"
 
87
>doesn't support</A
 
88
>.</P
 
89
><P
 
90
>One noticeable difference between SQLite and other SQL database engines is that the former is typeless. All data are stored as strings, and you can insert any type of data into any column. While the SQLite author has good reasons for this feature, it is an obstacle to using the strongly typed retrieval functions of libdbi. The only way out is to declare the column types in a <B
 
91
CLASS="COMMAND"
 
92
>CREATE TABLE</B
 
93
> statement just as you would with any other SQL database engine. As an example, the following statement is perfectly fine with SQLite, but not with the sqlite driver:</P
 
94
><TABLE
 
95
BORDER="0"
 
96
BGCOLOR="#000000"
 
97
WIDTH="100%"
 
98
><TR
 
99
><TD
 
100
><FONT
 
101
COLOR="#32CD32"
 
102
><PRE
 
103
CLASS="SCREEN"
 
104
><KBD
 
105
CLASS="USERINPUT"
 
106
>CREATE TABLE foo (a,b,c)</KBD
 
107
></PRE
 
108
></FONT
 
109
></TD
 
110
></TR
 
111
></TABLE
 
112
><P
 
113
>However, the following statement is fine with SQLite, the sqlite driver, and just about any other SQL database server:</P
 
114
><TABLE
 
115
BORDER="0"
 
116
BGCOLOR="#000000"
 
117
WIDTH="100%"
 
118
><TR
 
119
><TD
 
120
><FONT
 
121
COLOR="#32CD32"
 
122
><PRE
 
123
CLASS="SCREEN"
 
124
><KBD
 
125
CLASS="USERINPUT"
 
126
>CREATE TABLE foo (a INTEGER,b TEXT,c VARCHAR(64))</KBD
 
127
></PRE
 
128
></FONT
 
129
></TD
 
130
></TR
 
131
></TABLE
 
132
><P
 
133
>The following table lists the column types which are positively recognized by the sqlite driver. Essentially all column types supported by MySQL and PostgreSQL are supported by this driver as well, making it reasonably easy to write portable SQL code. All other column types are treated as strings.</P
 
134
><DIV
 
135
CLASS="TABLE"
 
136
><A
 
137
NAME="AEN135"
 
138
></A
 
139
><P
 
140
><B
 
141
>Table 4-1. SQL column types supported by the sqlite driver</B
 
142
></P
 
143
><TABLE
 
144
BORDER="1"
 
145
CLASS="CALSTABLE"
 
146
><COL><COL><THEAD
 
147
><TR
 
148
><TH
 
149
>type</TH
 
150
><TH
 
151
>description</TH
 
152
></TR
 
153
></THEAD
 
154
><TBODY
 
155
><TR
 
156
><TD
 
157
>TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB</TD
 
158
><TD
 
159
>String types of unlimited length. Binary data must be safely encoded, see text.</TD
 
160
></TR
 
161
><TR
 
162
><TD
 
163
>CHAR(), VARCHAR(), TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT</TD
 
164
><TD
 
165
>String types of unlimited length. There is no chopping or padding performed by the database engine.</TD
 
166
></TR
 
167
><TR
 
168
><TD
 
169
>ENUM</TD
 
170
><TD
 
171
>String type of unlimited length. In contrast to MySQL, choosing ENUM over VARCHAR does not save any storage space.</TD
 
172
></TR
 
173
><TR
 
174
><TD
 
175
>SET</TD
 
176
><TD
 
177
>String type of unlimited length. In contrast to MySQL, the input is not checked against the list of allowed values.</TD
 
178
></TR
 
179
><TR
 
180
><TD
 
181
>YEAR</TD
 
182
><TD
 
183
>String type of unlimited length. MySQL stores 2 or 4 digit years as a 1 byte value, whereas the SQLite drivers stores the string as provided.</TD
 
184
></TR
 
185
><TR
 
186
><TD
 
187
>TINYINT, INT1, CHAR</TD
 
188
><TD
 
189
>A 1 byte type used to store one character, a signed integer between -128 and 127, or an unsigned integer between 0 and 255.</TD
 
190
></TR
 
191
><TR
 
192
><TD
 
193
>SMALLINT, INT2</TD
 
194
><TD
 
195
>2 byte (short) integer type used to store a signed integer between -32768 and 32767 or an unsigned integer between 0 and 65535.</TD
 
196
></TR
 
197
><TR
 
198
><TD
 
199
>MEDIUMINT</TD
 
200
><TD
 
201
>3 byte integer type used to store a signed integer between -8388608 and 8388607 or an unsigned integer between 0 and 16777215.</TD
 
202
></TR
 
203
><TR
 
204
><TD
 
205
>INT, INTEGER, INT4</TD
 
206
><TD
 
207
>4 byte (long) integer type used to store a signed integer between -2147483648 and 2147483647 or an unsigned integer between 0 and 4294967295.</TD
 
208
></TR
 
209
><TR
 
210
><TD
 
211
>BIGINT, INT8</TD
 
212
><TD
 
213
>8 byte (long long) integer type used to store a signed integer between -9223372036854775808 and 9223372036854775807 or an unsigned integer between 0 and 18446744073709551615.</TD
 
214
></TR
 
215
><TR
 
216
><TD
 
217
>DECIMAL, NUMERIC</TD
 
218
><TD
 
219
>A string type of unlimited length used to store floating-point numbers of arbitrary precision.</TD
 
220
></TR
 
221
><TR
 
222
><TD
 
223
>TIMESTAMP, DATETIME</TD
 
224
><TD
 
225
>A string type of unlimited length used to store date/time combinations. The required format is 'YYYY-MM-DD HH:MM:SS', anything following this pattern is ignored.</TD
 
226
></TR
 
227
><TR
 
228
><TD
 
229
>DATE</TD
 
230
><TD
 
231
>A string type of unlimited length used to store a date. The required format is 'YYYY-MM-DD', anything following this pattern is ignored.</TD
 
232
></TR
 
233
><TR
 
234
><TD
 
235
>TIME</TD
 
236
><TD
 
237
>A string type of unlimited length used to store a time. The required format is 'HH:MM:SS', anything following this pattern is ignored.</TD
 
238
></TR
 
239
><TR
 
240
><TD
 
241
>FLOAT, FLOAT4, REAL</TD
 
242
><TD
 
243
>A 4 byte floating-point number. The range is -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38. Please note that MySQL treats REAL as an 8 byte instead of a 4 byte float like PostgreSQL.</TD
 
244
></TR
 
245
><TR
 
246
><TD
 
247
>DOUBLE, DOUBLE PRECISION, FLOAT8</TD
 
248
><TD
 
249
>An 8 byte floating-point number. The range is -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308.</TD
 
250
></TR
 
251
></TBODY
 
252
></TABLE
 
253
></DIV
 
254
><P
 
255
>Another difference is the lack of access control on the database engine level. Most SQL database servers implement some mechanisms to restrict who is allowed to fiddle with the databases and who is not. As SQLite uses regular files to store its databases, all available access control is on the filesystem level. There is no SQL interface to this kind of access control, but <B
 
256
CLASS="COMMAND"
 
257
>chmod</B
 
258
> and <B
 
259
CLASS="COMMAND"
 
260
>chown</B
 
261
> are your friends.</P
 
262
><P
 
263
>SQLite appears to implement row and column counters as C long int values. This limits the maximum number of rows somewhat compared to other SQL database engines.</P
 
264
><P
 
265
>SQLite does not have specific support for binary data. If you want to store binary data (e.g. character sequences containing NULL bytes) in a fashion that is portable across all database servers supported by libdbi, think about encoding these data, using either CGI-style or base64 algorithms. Free or public domain implementations of both algorithms can be found all over the place in the internet. The SQLite sources also contain a file <TT
 
266
CLASS="FILENAME"
 
267
>src/encode.c</TT
 
268
> that provides suitable endoding and decoding functions.</P
 
269
><P
 
270
>SQLite currently supports different character encodings only as compile-time options. There is no way to change the encoding at runtime or per database.</P
 
271
></DIV
 
272
><DIV
 
273
CLASS="NAVFOOTER"
 
274
><HR
 
275
ALIGN="LEFT"
 
276
WIDTH="100%"><TABLE
 
277
SUMMARY="Footer navigation table"
 
278
WIDTH="100%"
 
279
BORDER="0"
 
280
CELLPADDING="0"
 
281
CELLSPACING="0"
 
282
><TR
 
283
><TD
 
284
WIDTH="33%"
 
285
ALIGN="left"
 
286
VALIGN="top"
 
287
><A
 
288
HREF="c119.html"
 
289
ACCESSKEY="P"
 
290
>Prev</A
 
291
></TD
 
292
><TD
 
293
WIDTH="34%"
 
294
ALIGN="center"
 
295
VALIGN="top"
 
296
><A
 
297
HREF="index.html"
 
298
ACCESSKEY="H"
 
299
>Home</A
 
300
></TD
 
301
><TD
 
302
WIDTH="33%"
 
303
ALIGN="right"
 
304
VALIGN="top"
 
305
><A
 
306
HREF="x198.html"
 
307
ACCESSKEY="N"
 
308
>Next</A
 
309
></TD
 
310
></TR
 
311
><TR
 
312
><TD
 
313
WIDTH="33%"
 
314
ALIGN="left"
 
315
VALIGN="top"
 
316
>Peculiarities you should know about</TD
 
317
><TD
 
318
WIDTH="34%"
 
319
ALIGN="center"
 
320
VALIGN="top"
 
321
><A
 
322
HREF="c119.html"
 
323
ACCESSKEY="U"
 
324
>Up</A
 
325
></TD
 
326
><TD
 
327
WIDTH="33%"
 
328
ALIGN="right"
 
329
VALIGN="top"
 
330
>sqlite driver misfeatures</TD
 
331
></TR
 
332
></TABLE
 
333
></DIV
 
334
></BODY
 
335
></HTML
 
336
>
 
 
b'\\ No newline at end of file'