Re: [sqlite] Create Table oddity

2013-05-20 Thread Simon Slavin
On 20 May 2013, at 4:55am, Simon Slavin wrote: > I wonder if there's a difference between > > DEFAULT date('now') > > and > > DEFAULT (date('now')) Bah. Of course, you can't do either: "An explicit DEFAULT clause may specify that the default v

[sqlite] query help

2013-05-20 Thread Paul Sanderson
I have a table of the form create table tab (num int1 unique, num2, int) for each row for num2 there is usually a matching num1. But not always. I want to identify each row where num2 does not have a matching num1 example data might be num1 num2 1 3 2 3 3 2 4

Re: [sqlite] query help

2013-05-20 Thread Michael Black
I think this does what you want. create table tab (num1 int unique,num2 int); insert into tab values(1,3); insert into tab values(2,3); insert into tab values(3,2); insert into tab values(4,1); insert into tab values(5,11); insert into tab values(6,3); insert into tab values(7,9); sqlite> selec

Re: [sqlite] query help

2013-05-20 Thread Jay A. Kreibich
On Mon, May 20, 2013 at 12:59:45PM +0100, Paul Sanderson scratched on the wall: > I have a table of the form > > create table tab (num int1 unique, num2, int) > > for each row for num2 there is usually a matching num1. But not always. > > I want to identify each row where num2 does not have a ma

Re: [sqlite] query help

2013-05-20 Thread Igor Tandetnik
On 5/20/2013 7:59 AM, Paul Sanderson wrote: I have a table of the form create table tab (num int1 unique, num2, int) for each row for num2 there is usually a matching num1. But not always. I want to identify each row where num2 does not have a matching num1 select * from tab where num2 not i

Re: [sqlite] Create Table oddity

2013-05-20 Thread Keith Medcalf
It works quite fine: sqlite> create table a(a,b text default (datetime())); sqlite> insert into a (a) values (1); sqlite> insert into a (a) values (2); sqlite> select * from a; 1|2013-05-20 13:27:30 2|2013-05-20 13:27:34 --- () ascii ribbon campaign against html e-mail /\ www.asciiribbon.org

Re: [sqlite] query help

2013-05-20 Thread Keith Medcalf
select * from tab where not exists (select * from tab as tab2 where num1 = t1.num2); As you see, there are many ways to obtain the result you want ... This is a direct translation of the English "I want to identify each row where num2 does not have

Re: [sqlite] Create Table oddity

2013-05-20 Thread Simon Slavin
On 20 May 2013, at 2:41pm, Keith Medcalf wrote: > It works quite fine: > > sqlite> create table a(a,b text default (datetime())); > sqlite> insert into a (a) values (1); > sqlite> insert into a (a) values (2); > sqlite> select * from a; > 1|2013-05-20 13:27:30 > 2|2013-05-20 13:27:34 Interesti

[sqlite] autoincrement and primary key

2013-05-20 Thread Roman Fleysher
Dear SQLiters, I would like to use INTEGER PRIMARY KEY, but I would like to disable its implicit AUTOINCREMENT feature. Namely, if INSERT specifies value of the column, I would like uniqueness to be enforced, but if NULL is supplied, I would like the operation to fail instead of advancing key t

Re: [sqlite] autoincrement and primary key

2013-05-20 Thread Jean-Christophe Deschamps
I would like to use INTEGER PRIMARY KEY, but I would like to disable its implicit AUTOINCREMENT feature. Namely, if INSERT specifies value of the column, I would like uniqueness to be enforced, but if NULL is supplied, I would like the operation to fail instead of advancing key to a new integ

Re: [sqlite] autoincrement and primary key

2013-05-20 Thread Igor Tandetnik
On 5/20/2013 4:17 PM, Roman Fleysher wrote: I would like to use INTEGER PRIMARY KEY, but I would like to disable its implicit AUTOINCREMENT feature. Namely, if INSERT specifies value of the column, I would like uniqueness to be enforced, but if NULL is supplied, I would like the operation to f

Re: [sqlite] autoincrement and primary key

2013-05-20 Thread Roman Fleysher
Thank you, INTEGER -> INT solved the problem. According to manual, this will make search slower, but I give data integrity more weight for now. Roman From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on behalf of Igor Tandetnik [i.