欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

MySQL中使用load data命令實(shí)現(xiàn)數(shù)據(jù)導(dǎo)入的方法

 更新時(shí)間:2013年10月22日 23:23:40   作者:  
MySQL支持load data命令的數(shù)據(jù)導(dǎo)入,該方式比直接的insert的效率要高,按照官方的說法是要比insert語句快上20倍

使用方式如下:

復(fù)制代碼 代碼如下:
mysql>load data local infile "D:/ab.txt" into table mytbl(name,age);

使用上述的命令就可以將D:/ab.txt文件的內(nèi)容導(dǎo)入到表mytbl中,其中name和age是表mytbl的字段,對(duì)應(yīng)ab.txt文件中每行的數(shù)據(jù)。如果編譯安裝mysql時(shí)沒有指定

–enable-local-infile,那么在使用上述命令時(shí)會(huì)報(bào)如下錯(cuò)誤:

復(fù)制代碼 代碼如下:
ERROR 1148 (42000): The used command is not allowed with this MySQL version

 解決方式有兩種,一是重新編譯安裝加上上面的參數(shù),而是直接用命令行執(zhí)行,如下:

復(fù)制代碼 代碼如下:
mysql -uroot -proot  mydb_name --local-infile=1 -e 'load data local infile "D:/ab.txt" into table mytbl(name,age)'

測試了一把,導(dǎo)入300萬條數(shù)據(jù)時(shí),使用load data命令的時(shí)間花銷大概在3分鐘左右,還是非常不錯(cuò)的!

相關(guān)文章

最新評(píng)論