[tt]
mysql> SHOW CREATE TABLE products;
+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| products | CREATE TABLE `products` (
`product_id` int(10) unsigned NOT NULL auto_increment,
`product_description` varchar(100) default NULL,
`sku` varchar(7) default NULL,
`price` float NOT NULL,
`vendor_name` varchar(35) NOT NULL,
`vendor_id` int(11) NOT NULL,
`up_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`product_id`)
) ENGINE=MyISAM AUTO_INCREMENT=194 DEFAULT CHARSET=latin1 |
+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
[/tt]
This is the latest version of this table. works ok using mysql, gives all zeros for timestamp using dbi
[tt]
mysql> SHOW CREATE TABLE vendor;
+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| vendor | CREATE TABLE `vendor` (
`vendor_id` int(10) unsigned NOT NULL auto_increment,
`vendor_name` varchar(35) NOT NULL,
`vendor_address` varchar(100) NOT NULL,
`vendor_phone` varchar(25) default NULL,
`date_added` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`vendor_id`)
) ENGINE=MyISAM AUTO_INCREMENT=36 DEFAULT CHARSET=latin1 |
+--------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
[/tt]
gives all zeros through dbi also. Only works correctly if I actually enter an actual date through dbi
I simply cannot manage to create a date column that will work with dates only AND also update them automatically.
I've been at this silly issue for several days now.
I cannot find any example anywhere of how to create such a column, yet I read all over the place that this is possible
I tried the following and it fails to create a table
[tt]
CREATE TABLE returned ( return_date date NOT NULL default CURRENT_DATE ON UPDATE CURRENT_DATE);
[/tt]
most things I try give syntax error
or ERROR 1067 (42000): Invalid default value for 'return_date'
r937's suggestion does not work, still get all zeros unless I specify a real date