Re: [sqlite] insert default values

2006-07-28 Thread Mario Frasca
On 2006-0728 16:47:21, Nemanja Corlija wrote: > You can get that with this query: > select seq from sqlite_sequence where name='test' [...] > > There is also a last_insert_rowid() [...] > sqlite_sequence is really the way to go. very useful comments from everybody, thanks! Mario -- Power c

Re: [sqlite] insert default values

2006-07-28 Thread Nemanja Corlija
On 7/28/06, Mario Frasca <[EMAIL PROTECTED]> wrote: On 2006-0728 16:07:47, Nemanja Corlija wrote: > You can insert default value like this: > insert into test (f) values (NULL); > > Inserting NULL into autoincrement field just increments it. While > omitting value for any other field uses defaul

Re: [sqlite] insert default values

2006-07-28 Thread Mario Frasca
On 2006-0728 16:07:47, Nemanja Corlija wrote: > You can insert default value like this: > insert into test (f) values (NULL); > > Inserting NULL into autoincrement field just increments it. While > omitting value for any other field uses default for that field, if one > is defined. next question

Re: [sqlite] insert default values

2006-07-28 Thread Mario Frasca
On 2006-0728 07:05:54, Gerry Snyder wrote: > sqlite> insert into test (f) values (NULL); > sqlite> select * from test; > 1|1 > 2|2 > 3| > 4|0 I'm sorry, I did not see the message before... it is a bit of a funny behaviour, but I think I can live with it... thanks again, Mario -- Never, under a

Re: [sqlite] insert default values

2006-07-28 Thread Mario Frasca
Hi Gerry, yes, your help was quite useful... now we have two problems here, I would say: the first one is that, of all the things you have tried, only one is correct but two more are accepted without causing an error. On 2006-0728 06:55:22, Gerry Snyder wrote: > sqlite> create table test(f int a

Re: [sqlite] insert default values

2006-07-28 Thread Nemanja Corlija
On 7/28/06, Gerry Snyder <[EMAIL PROTECTED]> wrote: Finally, get it right: sqlite> create table test(f integer primary key autoincrement, v int default 0); sqlite> insert into test (v) values (1); sqlite> insert into test (v) values (2); sqlite> insert into test (v) values (NULL); sqlite> select

Re: [sqlite] insert default values

2006-07-28 Thread Gerry Snyder
Mario Frasca wrote: and how do I insert a 'all-default' record? After getting everything else right (see my previous post): sqlite> insert into test (f) values (NULL); sqlite> select * from test; 1|1 2|2 3| 4|0 And this answers my previous comment, too. Inserting a NULL into v overrides t

Re: [sqlite] insert default values

2006-07-28 Thread Christian Smith
Gerry Snyder uttered: Finally, get it right: sqlite> create table test(f integer primary key autoincrement, v int default 0); sqlite> insert into test (v) values (1); sqlite> insert into test (v) values (2); sqlite> insert into test (v) values (NULL); sqlite> select * from test; 1|1 2|2 3| No

Re: [sqlite] insert default values

2006-07-28 Thread Gerry Snyder
Mario Frasca wrote: I'm trying to use default values and autoincrementing primary keys. [EMAIL PROTECTED]:~$ sqlite3 /data/mariof/test.db_scia.db SQLite version 3.3.4 Enter ".help" for instructions sqlite> create table test(f int auto_increment primary key, v int default 0); The above is not