0
  • I have five column in .csv file and i have to import it in MySQL table.
  • But i also required date on which i import file in database.

So i mean six column in table with today date.

  • I have tried with use time stamp as datatype and CURRENT_TIMESTAMP in default.

But it occurs query:- Invalid column count in CSV input on line 1.

Please guide me.

Screen Shot:- enter image description here

Csv File:- enter image description here

Smit Saraiya
  • 391
  • 1
  • 5
  • 26

2 Answers2

3

This means the number of column in your csv and table is not same. If you want to set default value of any column you have to keep this value empty but you have to mention this column. For example: if you want to insert 3 columns having a default value for 1 column named 'created' your csv file should look like this:

enter image description here

Please remove first row which describes your table structure. I mean do not use the following instead of the above: enter image description here

And finally run the following sql if current timestamp is not set:

UPDATE `table` SET edate = current_timestamp;

Here put your table name it 'table' phrase.

Abdus Sattar Bhuiyan
  • 3,016
  • 4
  • 38
  • 72
0

You can use DEFAULT constraints to set the timestamp:

ALTER TABLE
 MODIFY edate datetime DEFAULT CURRENT_TIMESTAMP

ALTER TABLE
 MODIFY edate datetime DEFAULT ON UPDATE CURRENT_TIMESTAMP
lalithkumar
  • 3,480
  • 4
  • 24
  • 40