Select into OUTFILE   -- how do you append or delete

Posted on 2006-03-21
Last Modified: 2008-01-09
I have a query that will run and create the file right, however now I need to make some edits. First I need a version that will append to an existing file.... and another that will delete the file if it exists.  

so say I this was the query I was using what would it look like in the above situations...

SELECT insertstatement INTO OUTFILE 'C:\\MW2MP\\conversion.sql' from sqlinserts;
Question by:Isisagate
    1 Comment
    LVL 33

    Accepted Solution

    You can't from inside the mysql client.  You could from the command line, using redirection.
    mysql [options] -e "SELECT insertstaement FROM sqlinserts" > fileToOverWrite
    mysql [options] -e "SELECT insertstaement FROM sqlinserts" >> fileToAppend

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Suggested Solutions

    As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
    Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL ( several years ago, it seemed like now was a good time to updat…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now