From: | George Weaver <gweaver(at)shaw(dot)ca> |
---|---|
To: | Kenneth Gonsalves <lawgon(at)thenilgiris(dot)com>, Richard Huxton <dev(at)archonet(dot)com> |
Cc: | weberp(at)paradise(dot)net(dot)nz, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Query performance problem |
Date: | 2005-03-18 13:29:54 |
Message-ID: | 002101c52bbe$94689670$6400a8c0@Dell4500 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Only specifying a default value does not prevent a NULL from being entered
either through accident or ignorance:
jan28-05=# create table test (foo text, foo1 int4 default(0));
CREATE TABLE
jan28-05=# insert into test values('a',1);
INSERT 98685 1
jan28-05=# insert into test values('b',4);
INSERT 98686 1
jan28-05=# insert into test values('c',NULL);
INSERT 98687 1
jan28-05=# insert into test values('d');
INSERT 98688 1
jan28-05=# select * from test;
foo | foo1
-----+------
a | 1
b | 4
c |
d | 0
(4 rows)
George
----- Original Message -----
From: "Kenneth Gonsalves" <lawgon(at)thenilgiris(dot)com>
To: "Richard Huxton" <dev(at)archonet(dot)com>
Cc: <weberp(at)paradise(dot)net(dot)nz>; <pgsql-sql(at)postgresql(dot)org>
Sent: Thursday, March 17, 2005 11:19 PM
Subject: Re: [SQL] Query performance problem
On Thursday 17 Mar 2005 7:35 pm, Richard Huxton wrote:
> Not necessarily. NOT NULL here helps to ensure you can add values
> together without the risk of a null result. There are plenty of
> "amount" columns that should be not-null (total spent, total
> ordered etc).
that makes sense - but is it necessary to have a not null constraint
when there is a default value?
--
regards
kg
http://www.livejournal.com/users/lawgon
tally ho! http://avsap.sourceforge.net
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Patnude | 2005-03-18 16:32:25 | Re: best way to swap two records (computer details) |
Previous Message | Gary Stainburn | 2005-03-18 13:25:23 | best way to swap two records (computer details) |