How to import text file to table with primary key as auto-increment

后端 未结 7 1672
清歌不尽
清歌不尽 2020-12-09 17:29

I have some bulk data in a text file that I need to import into a MySQL table. The table consists of two fields ..

  1. ID (integer with auto-increment)
  2. Na
7条回答
  •  长情又很酷
    2020-12-09 18:25

    I just tried this:

    1. In phpMyAdmin table- match the amount of fields you have in your csv.
    2. Perform the import of csv data into your table
    3. Go to the [Structure] tab and add a new field [At beginning of table] (I assume you want the id field there)
    4. Fill in the [name] attribute as "id",
    5. [length] to "5"
    6. [Index] to "Primary"
    7. Tick the A_I (Auto Increment)
    8. Hit [Go] button
    9. The table should have updated with the id field at the front of all your data with auto-incrementing.

    At least this way you don't have to worry about matching fields, etc.

提交回复
热议问题