Re: NULL DATE

From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: NULL DATE
Date: 2009-10-17 07:55:17
Message-ID: 20091017075517.GA8080@tux
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

JORGE MALDONADO <jorgemal1960(at)gmail(dot)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°

In response to

  • NULL DATE at 2009-10-16 23:33:09 from JORGE MALDONADO

Browse pgsql-novice by date

  From Date Subject
Next Message Robert Haas 2009-10-17 10:56:56 Re: [PERFORM] Regarding facing lot of time Consumed by Socket.Poll()
Previous Message JORGE MALDONADO 2009-10-16 23:33:09 NULL DATE