Furrukh Jamal
Furrukh Jamal

Reputation: 142

ERROR 1067 (42000): Invalid default value for 'date_time' in MySQL

I am fairly new and was trying to upload a sql dump file which was working perfectly on my local machine, into a cloud 9. But on importing the file i am getting this error

ERROR 1067 (42000): Invalid default value for 'date_time'

The sql command in the dump file thats giving this error is

--
-- Table structure for table `history`
--

CREATE TABLE `history` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `action` varchar(4) NOT NULL,
  `symbol` varchar(20) NOT NULL,
  `company` varchar(255) NOT NULL,
  `shares` int(11) NOT NULL,
  `price` decimal(65,4) NOT NULL,
  `total` decimal(65,4) NOT NULL,
  `date_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;                    

--
-- Dumping data for table `history`
--

any help would be appreciated

Upvotes: 1

Views: 4345

Answers (1)

Anish
Anish

Reputation: 4988

You cannot use CURRENT_TIMESTAMP on update. Instead, change it to a TIMESTAMP.

Upvotes: 1

Related Questions