dongshi9489 2017-04-06 09:12
浏览 76
已采纳

在mysql中导入数据期间自动插入列

  • 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

  • 写回答

2条回答 默认 最新

  • dsizd368332 2017-04-06 09:29
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳