Search code examples
mysqlinto-outfile

Include headers when using SELECT INTO OUTFILE?


Is it possible to include the headers somehow when using the MySQL INTO OUTFILE?


Solution

  • You'd have to hard code those headers yourself. Something like:

    SELECT 'ColName1', 'ColName2', 'ColName3'
    UNION ALL
    SELECT ColName1, ColName2, ColName3
        FROM YourTable
        INTO OUTFILE '/path/outfile'