有时候需要给数据库导入多个文本数据,每次等待非常浪费时间,所以自己写成SQL脚本,让程序自动执行,就不需要等待了。

命令:

mysql -u root -prootp testt <a.sql

mysql同时执行导入多条语句_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';

mysql同时执行导入多条语句_多条语句_02

测试结果:

mysql同时执行导入多条语句_sql_03



参考链接:

http://www.oschina.net/question/227902_163001 for 逝水fox