开发者

Creating CSV files via MySQL - Any limits imposed?

开发者 https://www.devze.com 2023-03-04 05:13 出处:网络
I am going to be creating some CSV files via MySQL with code like the below for example.. SELECT id, name, email INTO OUTFILE \'/tmp/result.csv\'

I am going to be creating some CSV files via MySQL with code like the below for example..

SELECT id, name, email INTO OUTFILE '/tmp/result.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
ES开发者_如何转开发CAPED BY ‘\\’
LINES TERMINATED BY '\n'
FROM users WHERE 1

But I was just wondering if the resulting file is going to be rather large (possibly several GB's) is there things I should be concerned about or precautions I should take? Like memory problems etc?


Ram shouldn't be an issue, but you'll want to make sure the volume you are writing it to can handle that large of a file. I've seen a lot of guys get stuck at 2GB or 4 GB because their file system couldn't handle files larger than that.

Also, I recommend writing it to a local drive on the MySQL machine and then copying it over the network or other means. Writing that large of a file could take quite a while if your network isn't at least Gigabit.

One more suggestion... try it on about 1000 rows or so first, and then test your CSV against your target environment. Sometimes it takes a few tries to get the formatting where you want it.

0

精彩评论

暂无评论...
验证码 换一张
取 消