How to do a batch insert in MySQL

后端 未结 5 1611
离开以前
离开以前 2020-11-22 10:29

I have 1-many number of records that need to be entered into a table. What is the best way to do this in a query? Should I just make a loop and insert one record per itera

5条回答
  •  名媛妹妹
    2020-11-22 11:26

    Load data infile query is much better option but some servers like godaddy restrict this option on shared hosting so , only two options left then one is insert record on every iteration or batch insert , but batch insert has its limitaion of characters if your query exceeds this number of characters set in mysql then your query will crash , So I suggest insert data in chunks withs batch insert , this will minimize number of connections established with database.best of luck guys

提交回复
热议问题