Re: A couple of newbie questions ... - Mailing list pgsql-general

From John DeSoi
Subject Re: A couple of newbie questions ...
Date
Msg-id 34DBDC21-DBCD-4A39-AC05-BEFA9629DB50@pgedit.com
Whole thread Raw
In response to Re: A couple of newbie questions ...  (Shane Ambler <pgsql@Sheeky.Biz>)
List pgsql-general
On Jul 23, 2008, at 12:00 PM, Shane Ambler wrote:

> To be honest I hadn't seen the use of INSERT INTO table (fld_x,
> fld_y,fld_z) VALUES (DEFAULT, 'y','z') before, I have always gone
> with INSERT INTO table (fld_x, fld_y,fld_z) VALUES (NULL, 'y','z')
>
> is DEFAULT a better option than using NULL? or is it just a
> preference to spell out the implied default entry?
>
> I've only used DEFAULT in CREATE TABLE(...)

The semantics of using DEFAULT or NULL is completely different. If the
column has a default value (for example, 0), then including DEFAULT in
your insert list will give you the default value of zero. But if you
include NULL in your insert list -- you'll get NULL, not zero. If
nothing is included for the column in your insert list, you'll get the
column default if it has one, otherwise NULL.


John DeSoi, Ph.D.





pgsql-general by date:

Previous
From: Alex Cheshev
Date:
Subject: Sequence
Next
From: admin
Date:
Subject: Re: php + postgresql