Re: [SQL] DEFAULT TEXT 'now'

From: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] DEFAULT TEXT 'now'
Date: 1999-03-24 16:26:55
Message-ID: 36F9124F.E2460C2C@rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Anatoly K. Lasareff wrote:
>
> >>>>> "RJLG" == Roberto Joao Lopes Garcia <roberto(at)mha(dot)com(dot)br> writes:
>
>> <snipped problem with using default 'now'>

> <snipped description of using now() instead>

What version of postgresql are you all using? I tried RJLG's example
code with 6.4.2, and it worked - I got different times at each insert,
so the default 'now' was being calculated at insertion time, not table
creation time. Here's what it looks like:

test2=> \d conex

Table = conex
+----------------------------------+----------------------------------+-------+
| Field | Type |
Length|
+----------------------------------+----------------------------------+-------+
| id | int4 not null default nextval (
| 4 |
| inicio | datetime default text 'now'
| 8 |
| ultimo | datetime default text 'now'
| 8 |
| ip | inet
| var |
+----------------------------------+----------------------------------+-------+
Index: conex_pkey
test2=> select * from conex;
id|inicio |ultimo
| ip
--+----------------------------+----------------------------+---------------
1|Tue Mar 23 13:40:24 1999 CST|Tue Mar 23 13:40:24 1999
CST|200.200.200.200
2|Tue Mar 23 13:40:28 1999 CST|Tue Mar 23 13:40:28 1999
CST|200.200.200.202
3|Tue Mar 23 13:40:30 1999 CST|Tue Mar 23 13:40:30 1999
CST|200.200.200.203
4|Tue Mar 23 13:41:06 1999 CST|Tue Mar 23 13:41:06 1999
CST|200.200.200.203
5|Tue Mar 23 13:41:21 1999 CST|Tue Mar 23 13:41:21 1999
CST|200.200.200.205
(5 rows)

test2=>

???

Ross

--
Ross J. Reedstrom, Ph.D., <reedstrm(at)rice(dot)edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jenny DiBartolomeo 1999-03-24 18:49:37 Comparing Dates to Current Time
Previous Message Rich Shepard 1999-03-24 13:55:37 Re: [SQL] Use of 'default TEXT now()'