如何将CSV加载到MySQL?
问题描述:
我使用mysql和Php
Im using mysql and Php
我尝试了几次,但始终没有插入数据.请帮助我做到这一点.
I tried several times but always didnt insert data. please help me to do this.
我有一个名为"db_master"的MySQL表. "ID"字段为自动递增
I have MySQL table called 'db_master'. 'ID' feild is auto increment
this is my table
我有一个名为'csv_master'的csv文件-没有列标题.
and i have csv file called 'csv_master' - no column headings..
this is my csv file -
请帮助我在表(db_master)中输入CSV文件-需要PHP代码
please help me to input CSV file my table (db_master) - PHP CODE REQUIRED
提前谢谢.
答
mysql> LOAD DATA LOCAL INFILE './csv_master.csv' INTO TABLE your_db.db_master FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';