此问题在此处已有答案:
How do I import CSV file into a MySQL table?(21个答案)
上个月关门了。
如何将大型txt文件转换为mysql数据库,文件大小为3GB,包含1100万行。文件中的每一行都是这样的:
"1303179444","","","+20******5811","","","Ahmed","Al Emam","male","/ahmed.e.alemam","","ahmed.e.alemam","Ahmed Al Emam","description here","Ahmed Emam Dental Clinic","Dentist","","Dekernes Ad Daqahliyah iraq","MUST","ahmed.e.alemam@ahmed.e.alemam","0","0","0","1/1/0001 12:00:00 AM","1/1/0001 12:00:00 AM","","","","","","","","","",""
我试图用逗号分隔并通过php将数据输入到数据库中,但这花了很长时间,整个文件没有保存。我想用另一种方法将其转换为sql文件
1条答案
按热度按时间xxhby3vn1#
您可以使用mysql LOAD DATA INFILE命令完成此任务。
首先创建表:
然后执行以下命令:
还可以指定文件中的列与表中的列之间的Map,甚至可以更改。
例如,假设您要Map:
您可以使用以下命令: