From: "Michal Dvoracek" <[EMAIL PROTECTED]> > s possible to create table with default value returned by built-in > function ?? > like: > > create table x (a int not null default UNIX_TIMESTAMP()); > > When inserting new column in table field a will contains timestamp?
In general, this cannot be done. Default values cannot be the return of a MySQL function (as much as I'd love to use NOW() for default values!). However, there's one loophole. When inserting, not specifying a value for the first timestamp field in a table will generate the current timestamp. For example: ------------------------------------------------------ CREATE TABLE foo ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, email VARCHAR(50), entered TIMESTAMP ); INSERT INTO foo SET email='[EMAIL PROTECTED]'; SELECT * FROM foo; DROP TABLE foo; ------------------------------------------------------ This will return: +----+--------------+----------------+ | id | email | entered | +----+--------------+----------------+ | 1 | [EMAIL PROTECTED] | 20020320092330 | +----+--------------+----------------+ 1 row in set (0.00 sec) This won't give you UNIX_TIMESTAMP(), but it gives you the YYYYMMDDhhmmss timestamp. Does that help? -- denonymous www.coldcircuit.net --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php