How to LOAD DATA INFILE in mysql with first col being Auto Increment?

后端 未结 7 2022
离开以前
离开以前 2020-11-30 02:05

Currently, We have a table similar to this:

---------------------
ID | AField | BField|
---------------------

The ID is Auto Increment

7条回答
  •  旧巷少年郎
    2020-11-30 03:09

    The best thing to do is just include the 2 non-auto-increment columns in the CSV, and then explicitly set the ID column to NULL in the load data infile statement.

    Something like this:

    LOAD DATA INFILE '/tmp/data.csv'
    INTO TABLE your_table
    FIELDS TERMINATED BY ','
    (AField, BField)
    SET ID = NULL;
    

提交回复
热议问题