Обсуждение: NULL DATE

Поиск
Список
Период
Сортировка

NULL DATE

От
JORGE MALDONADO
Дата:
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.
 
Respectfully,
Jorge Maldonado

Re: NULL DATE

От
Andreas Kretschmer
Дата:
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°