On Wed, Oct 12, 2005 at 08:23:15PM +0100, Oliver Elphick wrote: > On Wed, 2005-10-12 at 12:13 -0600, Michael Fuhr wrote: > > On another note, regarding the following: > > > > > invdate | date | not null default > > > ('now'::text)::date > > > taxpoint | date | not null default > > > ('now'::text)::date > > > > Are you sure you want 'now'::text as a default, considering the > > warning against it? > > I actually use CURRENT_DATE; that is what the system turns it into.
Ah yes, I see that now. I generally use now(), so I hadn't noticed that CURRENT_DATE and CURRENT_TIMESTAMP become 'now', whereas only a literal 'now' is expanded at create time: CREATE TABLE foo ( d1 date NOT NULL DEFAULT now(), d2 date NOT NULL DEFAULT CURRENT_DATE, d3 date NOT NULL DEFAULT 'now' ); \d foo Table "public.foo" Column | Type | Modifiers --------+------+-------------------------------------- d1 | date | not null default now() d2 | date | not null default ('now'::text)::date d3 | date | not null default '2005-10-12'::date -- Michael Fuhr ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq