1

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

chanafdo
  • 5,016
  • 3
  • 29
  • 46
Furrukh Jamal
  • 142
  • 3
  • 14
  • I believe this should help: https://stackoverflow.com/questions/168736/how-do-you-set-a-default-value-for-a-mysql-datetime-column?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – apomene Apr 17 '18 at 11:59
  • that helped thanks, I needed to update my mysql – Furrukh Jamal Apr 17 '18 at 15:17

1 Answers1

1

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

Anish
  • 4,262
  • 6
  • 36
  • 58