Re: Explicitly inserting NULL values into NOT NULL DEFAULT 0 columns

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Tanmay Patel <tan(dot)patel(dot)may(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Explicitly inserting NULL values into NOT NULL DEFAULT 0 columns
Date: 2011-11-22 04:54:27
Message-ID: CAOR=d=3dK4wj9808hneDV5T4yO1qErsQL6=FMm0_XFi1O7DPyA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Nov 21, 2011 at 5:27 PM, Tanmay Patel <tan(dot)patel(dot)may(at)gmail(dot)com> wrote:
> If I insert a NULL value explicitly into a column declared to be NOT NULL
> DEFAULT 0 in postgreSQL 8.4 the column ends up with the default value. If I
> do the same in postgreSQL 9.0 I get an error about how I am inserting a null
> value into a NOT NULL column.

As Tom pointed out you are mistaken. That's a MySQLism. If you want
to insert defaults, use the DEFAULT keyword in place of where you're
trying to put NULL.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ashesh Vashi 2011-11-22 05:13:45 Re: Installing postgresql on windows 7
Previous Message Tom Lane 2011-11-22 04:22:09 Re: Explicitly inserting NULL values into NOT NULL DEFAULT 0 columns