Sophie

Sophie

distrib > Mandriva > 10.0 > i586 > media > contrib > by-pkgid > 9b886a1040875f5e5767f2f3ecb954f1 > files > 13

libdbi-drivers-dbd-sqlite-0.7.0-1mdk.i586.rpm

<HTML
><HEAD
><TITLE
>SQLite (mis)features</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.73
"><LINK
REL="HOME"
TITLE="sqlite driver manual"
HREF="index.html"><LINK
REL="UP"
TITLE="Peculiarities you should know about"
HREF="c119.html"><LINK
REL="PREVIOUS"
TITLE="Peculiarities you should know about"
HREF="c119.html"><LINK
REL="NEXT"
TITLE="sqlite driver misfeatures"
HREF="x198.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>sqlite driver manual: A libdbi driver using the SQLite embedded database engine</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="c119.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 4. Peculiarities you should know about</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x198.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="AEN122"
>4.1. SQLite (mis)features</A
></H1
><P
>As the SQLite package is constantly being improved, you should refer to the original documentation about the SQL features it <A
HREF="http://www.sqlite.org/lang.html"
TARGET="_top"
>supports</A
> and about the SQL features it <A
HREF="http://www.sqlite.org/omitted.html"
TARGET="_top"
>doesn't support</A
>.</P
><P
>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
CLASS="COMMAND"
>CREATE TABLE</B
> 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
><TABLE
BORDER="0"
BGCOLOR="#000000"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#32CD32"
><PRE
CLASS="SCREEN"
><TT
CLASS="USERINPUT"
><B
>CREATE TABLE foo (a,b,c)</B
></TT
></PRE
></FONT
></TD
></TR
></TABLE
><P
>However, the following statement is fine with SQLite, the sqlite driver, and just about any other SQL database server:</P
><TABLE
BORDER="0"
BGCOLOR="#000000"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#32CD32"
><PRE
CLASS="SCREEN"
><TT
CLASS="USERINPUT"
><B
>CREATE TABLE foo (a INTEGER,b TEXT,c VARCHAR(64))</B
></TT
></PRE
></FONT
></TD
></TR
></TABLE
><P
>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
><DIV
CLASS="TABLE"
><A
NAME="AEN135"
></A
><P
><B
>Table 4-1. SQL column types supported by the sqlite driver</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><THEAD
><TR
><TH
ALIGN="LEFT"
VALIGN="TOP"
>type</TH
><TH
ALIGN="LEFT"
VALIGN="TOP"
>description</TH
></TR
></THEAD
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>String types of unlimited length. Binary data must be safely encoded, see text.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>CHAR(), VARCHAR(), TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>String types of unlimited length. There is no chopping or padding performed by the database engine.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>ENUM</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>String type of unlimited length. In contrast to MySQL, choosing ENUM over VARCHAR does not save any storage space.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>SET</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>String type of unlimited length. In contrast to MySQL, the input is not checked against the list of allowed values.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>YEAR</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>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
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>TINYINT, INT1, CHAR</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>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
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>SMALLINT, INT2</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>2 byte (short) integer type used to store a signed integer between -32768 and 32767 or an unsigned integer between 0 and 65535.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>MEDIUMINT</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>3 byte integer type used to store a signed integer between -8388608 and 8388607 or an unsigned integer between 0 and 16777215.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>INT, INTEGER, INT4</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>4 byte (long) integer type used to store a signed integer between -2147483648 and 2147483647 or an unsigned integer between 0 and 4294967295.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>BIGINT, INT8</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>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
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>DECIMAL, NUMERIC</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>A string type of unlimited length used to store floating-point numbers of arbitrary precision.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>TIMESTAMP, DATETIME</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>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
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>DATE</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>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
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>TIME</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>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
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>FLOAT, FLOAT4, REAL</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>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
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>DOUBLE, DOUBLE PRECISION, FLOAT8</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>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
></TR
></TBODY
></TABLE
></DIV
><P
>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
CLASS="COMMAND"
>chmod</B
> and <B
CLASS="COMMAND"
>chown</B
> are your friends.</P
><P
>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
><P
>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
CLASS="FILENAME"
>src/encode.c</TT
> that provides suitable endoding and decoding functions.</P
><P
>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
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="c119.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x198.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Peculiarities you should know about</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c119.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>sqlite driver misfeatures</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>