At 3:51 PM -0500 09-11-2000, Will Stranathan wrote:
>I want a DATETIME field that, when a row is created, is auto-populated to
>the current timestamp, however, I DON'T want the field updated when the
>record is modified, AND I want to allow NULL values on the field. However:
>
>CREATE TABLE FOO (
> ID INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
> THISDATE DATETIME NULL DEFAULT 'CURRENT_TIMESTAMP'
>);
Default values can only be constants.
Your statement specifies a default value consisting of the string
'CURRENT_TIMESTAMP'. Not what you want.
You'll need to set the value explicitly to the current timestamp
when you create records.
>
>INSERT INTO FOO () VALUES ();
>
>SELECT * FROM FOO;
>
>yeilds:
>
>+----+---------------------+
>| ID | THISDATE |
>+----+---------------------+
>| 1 | 0000-00-00 00:00:00 |
>+----+---------------------+
>
>I want the THISDATE field to have the date and time that the record was
>entered. Is there a way to do this without a TIMESTAMP? (Since I don't
>want the field updated every time, and I want to be able to explicitly go
>back and set the field to NULL).
--
Paul DuBois, paul@stripped