有时候需要给数据库导入多个文本数据,每次等待非常浪费时间,所以自己写成SQL脚本,让程序自动执行,就不需要等待了。
命令:
mysql -u root -prootp testt <a.sql
-u后面是数据库用户名
-p后面是数据库密码
testt是数据库
a.sql是我要执行的SQL脚本。
下图是我要测试内容:
Load data local infile '/data/tt1.txt' into table Sgk_test.22 fields terminated by '\t';
Load data local infile '/data/tt2.txt' into table Sgk_test.22 fields terminated by '\t';
测试结果:
参考链接:
http://www.oschina.net/question/227902_163001 for 逝水fox
转载于:https://blog.51cto.com/wutou/1793901