ok... That explains how autoincrement works, but it doesn't explain
why the AUTO_INCREMENT keyword made it through the parser without
raising an error or doing what I would expect - and work as an
AUTOINCREMENT table.


perhaps, it is the same reason this works:

sqlite> create table abc (id not null default 0);
sqlite>

This works, probably because sqlite doesn't enforce column types...
but it would be nice if this sort of syntax error was caught...  eg, I
had made the mistake of:
create table abc (`column integer` not null default 0);
and then wondered why "   select column from abc; "  didn't work !

not essential, just a nice-to-have.

thanks
Paul



On 09/08/07, miguel manese <[EMAIL PROTECTED]> wrote:
> Igor has answered this before. Roughly:
>
> 1. all tables has an implicit integer column named "rowid" that is
> auto increment
> 2. creating an integer primary key effectively "renames" rowid to that
> column, so in your case below fields id and rowid are the same
>
> IIRC drh replied something else, and since I'm not familiar with the
> internals I'm not sure if that is how it is implemented or an
> equivalent black-box model of how sqlite works. But since Igor is like
> the next authoritative guru here after drh himself, that explanation
> should be correct.
>
> Cheers,
> M. Manese
>
> On 8/9/07, Paul Harris <[EMAIL PROTECTED]> wrote:
> > I dislike answering myself, but no sooner I had sent that email, I tried 
> > this:
> >
> > sqlite> create table ghi (id integer primary key autoincrement, value text);
> > sqlite> insert into ghi (value) values ('justvalue');
> > sqlite> insert into ghi (id,value) values (null,'withid');
> > sqlite> select * from ghi;
> > id|value
> > 1|justvalue
> > 2|withid
> > sqlite>
> >
> > so, why doesn't auto_increment do either of the following more sensible 
> > things:
> > 1) throw an error
> > 2) do what "autoincrement" does
> >
> > ?
> >
> > thanks
> > Paul
> >
> > -----------------------------------------------------------------------------
> > To unsubscribe, send email to [EMAIL PROTECTED]
> > -----------------------------------------------------------------------------
> >
> >
>
> -----------------------------------------------------------------------------
> To unsubscribe, send email to [EMAIL PROTECTED]
> -----------------------------------------------------------------------------
>
>

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

Reply via email to