tags:

views:

155

answers:

1

Hi,

I need to find a way to insert a file header (not column header) and dump my data after that.

How would you do that ?

Regards,

+1  A: 

Not quite a "clean" solution, but this works.

Linux or Unix terminal:

prompt$ echo YourFileHeader > aFile.txt ; mysql -u YOUR_USER -p YOUR_DATABSE --execute="SELECT ..." >> aFile.txt

Windows command window (you have to type the commands one by one):

c:\> echo YourFileHeader > aFile.txt
c:\> mysql -u YOUR_USER -p YOUR_DATABSE --execute="SELECT ..." >> aFile.txt

MySQL will prompt for your password.

I do believe select ... into outfile... is a bit slow, I've had always better results using this solutions. Downside: The query output will have the field and line default terminators (\t and \n respectively)... I don't know if there's a way to tweak this from shell.

Hope this works for you.

Barranka
I finally used something like that except it is on GNU/linux.Thank you.
Xavier Maillard