MySQL INTO OUTFILE override existing file?

后端 未结 7 1620
抹茶落季
抹茶落季 2020-12-05 06:19

I\'ve written a big sql script that creates a CSV file. I want to call a cronjob every night to create a fresh CSV file and have it available on the website.

Say for

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 06:55

    No, there's no way to overwrite it. From the docs:

    file_name cannot be an existing file, which among other things prevents files such as /etc/passwd and database tables from being destroyed.

    It might be a better idea to use a different filename each night, as having multiple backups means you can recover from problems that have existed for more than a day. You could then maintain a symlink that always points at the latest complete csv.

提交回复
热议问题