CleverCode在实际的工作中,经常需要将一些报表,或者日志数据等导出来,如果直接做页面,如果次数也不是很多,需求也不同。所以直接导出csv文件,更加直观。
into outfile ‘目标文件’,目标文件是保存在mysql的服务器端,因为sql语句都是在服务器端执行了。所以执行完后目标文件会保存在mysql服务器端。into outfile '/tmp/test.csv',一般是mysql服务器是在linux上;into outfile 'e:/test.csv' ,一般是mysql服务器端在windows上。并且目标文件必须有写入权限,而且文件不能存在。
select
*
from proxy_list
order by id asc
limit 0,2
into outfile '/tmp/test.csv'
fields
terminated by ','
optionally enclosed by '"'
escaped by '"'
lines terminated by '\r\n'; select uid, nation from system_user order by uid asc limit 0,2 into outfile 'e:/test.csv' fields terminated by ',' optionally enclosed by '"' escaped by '"' lines terminated by '\r\n';


每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号