public inbox for [email protected]
help / color / mirror / Atom feedFrom: Lourival Oliveira <[email protected]>
To: [email protected]
Subject: Default Values Section
Date: Tue, 4 Jan 2005 14:51:19 -0300
Message-ID: <009401c4f286$01cc6b50$fc00a8c0@hermes> (raw)
I have a problem reading the "5.3 Default Values" Section of
Postgresql8.0.0-rc1 documentation. In this section there are nothing about
using 'now' constant. I think which there are a conflict with a note about
'now' in section "9.9. Date/Time Functions and Operators" which show the way
to achieve the desired behavior. See:
5.3. Default Values
...
The default value may be a scalar expression, which will be evaluated
whenever the default value is inserted (not when the table is created).
9.9. Date/Time Functions and Operators
...
SELECT CURRENT_TIMESTAMP;
SELECT now();
SELECT TIMESTAMP 'now';
Note: You do not want to use the third form when specifying a DEFAULT clause
while creating a table. The system will convert now to a timestamp as soon
as the constant is parsed, so that when the default value is needed, the
time of the table creation would be used! The first two forms will not be
evaluated until the default value is used, because they are function calls.
Thus they will give the desired behavior of defaulting to the time of row
insertion.
I think which a simple reference to any unpredictable behavior must be
placed here to avoid confusion when anybody don't reach the desired behavior
when use default values.
What think you about my suggestion?
Wait replies, Tanks.
Lourival Oliveira da Silva
PS: Sorry by my poor English.
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: Default Values Section
In-Reply-To: <009401c4f286$01cc6b50$fc00a8c0@hermes>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox