From: | John DeSoi <desoi(at)pgedit(dot)com> |
---|---|
To: | Shane Ambler <pgsql(at)sheeky(dot)biz> |
Cc: | Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: A couple of newbie questions ... |
Date: | 2008-07-26 01:36:13 |
Message-ID: | 34DBDC21-DBCD-4A39-AC05-BEFA9629DB50@pgedit.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | admin | 2008-07-26 01:43:15 | Re: php + postgresql |
Previous Message | Alex Cheshev | 2008-07-26 01:21:10 | Sequence |