pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: George Weaver <gweaver@shaw.ca>
To: Kenneth Gonsalves <lawgon@thenilgiris.com>
To: Richard Huxton <dev@archonet.com>
Cc: weberp@paradise.net.nz
Cc: pgsql-sql@postgresql.org
Subject: Re: Query performance problem
Date: Fri, 18 Mar 2005 07:29:54 -0600
Message-ID: <002101c52bbe$94689670$6400a8c0@Dell4500> (raw)
References: <200503172120.20676.weberp@paradise.net.nz>
	<200503171801.19412.lawgon@thenilgiris.com>
	<42398EB9.2050707@archonet.com>
	<200503181049.47566.lawgon@thenilgiris.com>

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@thenilgiris.com>
To: "Richard Huxton" <dev@archonet.com>
Cc: <weberp@paradise.net.nz>; <pgsql-sql@postgresql.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@postgresql.org)





view thread (10+ messages)

Message-ID: <002101c52bbe$94689670$6400a8c0@Dell4500>
Permalink:  ../002101c52bbe$94689670$6400a8c0@Dell4500/
Also on:    postgresql.org/message-id/002101c52bbe$94689670$6400a8c0@Dell4500

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gweaver@shaw.ca, lawgon@thenilgiris.com, dev@archonet.com, weberp@paradise.net.nz
  Subject: Re: Query performance problem
  In-Reply-To: <002101c52bbe$94689670$6400a8c0@Dell4500>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox