Re: NULL DATE - Mailing list pgsql-novice

From Andreas Kretschmer
Subject Re: NULL DATE
Date
Msg-id 20091017075517.GA8080@tux
Whole thread Raw
In response to NULL DATE  (JORGE MALDONADO <jorgemal1960@gmail.com>)
List pgsql-novice
JORGE MALDONADO <jorgemal1960@gmail.com> wrote:

> Is it possible to set a date field to nothing or null? Sometimes I need to
> initially save a date field without information and modify it later.

Sure, use NULL instead a real date.

test=# create table Jorge (id serial, d date);
HINWEIS:  CREATE TABLE erstellt implizit eine Sequenz »jorge_id_seq« für die »serial«-Spalte »jorge.id«
CREATE TABLE
Time: 207.424 ms
test=*# insert into jorge values(default, null);
INSERT 0 1
Time: 0.315 ms
test=*# insert into jorge values(default, current_date);
INSERT 0 1
Time: 0.536 ms
test=*# select * from jorge;
 id |     d
----+------------
  1 |
  2 | 2009-10-17
(2 rows)

Time: 0.260 ms
test=*#


Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°

pgsql-novice by date:

Previous
From: JORGE MALDONADO
Date:
Subject: NULL DATE
Next
From: roody senecal
Date:
Subject: Synch to Database with same schema.