Mark Wyszomierski <[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> I switched to sqlite from mysql awhile ago, I maintained the field types
> in my sqlite implementation such as:
> 
>     create table students (first_name TEXT, age INTEGER);
> 
> I'm just wondering if there is any point to specifying the field type as if
> I try adding a string type into the age field, it seems to be accepted ok:
> 
>     insert into students values('hello');
> 
> Does sqlite have any problem regarding setting a field defined as INTEGER
> from a text string (any limits etc?), are there any performance gains to be
> had with specifying the field type?
> 

If you have a table like this:

   CREATE TABLE ex1(part_number INTEGER);

And then you insert text that looks like a number but has
leading zeros:

   INSERT INTO ex1 VALUES('000123');

The string gets converted into an integer.  You can read it
back out as a string if that is what you want, but the leading
zeros will get lost.  If you want to preserve the leading zeros,
you have to make sure the type of the column is TEXT:

   CREATE TABLE ex1(part_number TEXT);

Other than some really strange corner cases like the above,
the type of the column does not matter in SQLite.
--
D. Richard Hipp <[EMAIL PROTECTED]>

Reply via email to