Look at the sqlite docimentation and read all about "manifest typing". That will explain why VARCHAR and CHAR don't exist as distinct types, and why.

Note that Sqlite stores the VARCHAR as the declared type, but makes it own decision as to the storage type. If VARCHAR is important to your application you can access the declared types through the API.

Mario Figueiredo wrote:
Hello everyone,

I plan to incorprorate SQLite with my C++ projects. I have read the
documentation on how it manages datatypes and I believe I understood it.
However I still have a few doubts that don't seem to be covered by the
documentation.

Are ANSI datatypes recognized? I'm particularly interested in CHAR(X) and
VARCHAR(X). And they seem to work in a way I can't understand.

Within sqlite3 shell I create a simple test table:

CREATE TABLE mytable (
   col1 CHAR(5),
   col2 VARCHAR(5),
   col3 INTEGER
)

and insert the following values:

INSERT INTO mytable VALUES('W23456','W23456',1)

The 6 character long strings are not truncated or an SQL error issued. A
select statement on the table reveals the 5 character lenght constraint to
not have been obeyed. The output is:

W23456|W23456|1

However, when using an external tool (SQLite Administrator 0.8.2.6 Beta) to
read the table, it does show both fields truncated to 5 characters.

So I'm a little confused. What is indeed happening? Is the constraint being
applied only when reading data? And then only when some command is appended
to the select statement?

Thank you,
Mario Figueiredo



-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to