v.23.6New Feature
Add TRUNCATE Modifier Support to INTO OUTFILE Clause
Add support forTRUNCATEmodifier inINTO OUTFILEclause. Suggest usingAPPENDorTRUNCATEforINTO OUTFILEwhen file exists. #50950 (alekar).
Why it matters
This feature addresses the need to control the behavior when exporting query results to a file usingINTO OUTFILE. It allows users to explicitly choose whether to overwrite (truncate) the existing file or append to it, preventing unintentional data duplication or loss.How to use it
When using theINTO OUTFILE clause in your SQL query, specify either the TRUNCATE or APPEND modifier to control file handling. For example:SELECT * FROM table INTO OUTFILE 'file.csv' FORMAT CSV TRUNCATE;This will overwrite the existing file. Alternatively, use
APPEND to add to the file.