Unable to create a table in database

Gafoor

This is the query I have used for creating the table

   CREATE TABLE IF NOT EXISTS `logging_api_request_js` (
      `id` int(30) unsigned NOT NULL AUTO_INCREMENT,
      `log_message` longtext,
      `level` varchar(10) DEFAULT NULL,
      `ip_address_merchant` varchar(45) DEFAULT NULL,
      `ip_address_customer` varchar(45) DEFAULT NULL,
      `creationTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      `updateTime` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 

It showed an error Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

When I googled I saw that in the mysql 5.6. version this issue / restriction has been took off.But i wont be able to upgrade mysql right now.

Is there any work around for this,whith out changing the table structure to dump this using mysql?Please help.Im having little knowledge about the db operations.Do help.Thanks

sectus

You could remove ON UPDATE CURRENT_TIMESTAMP and create trigger.

DROP TRIGGER IF EXISTS `update_logging_api_request_js`;
DELIMITER //
CREATE TRIGGER `update_logging_api_request_js` BEFORE UPDATE ON `logging_api_request_js`
 FOR EACH ROW BEGIN  
        SET NEW.updateTime = NEW.creationTime;   
END
//
DELIMITER ;

Collected from the Internet

Please contact javaer1[email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related