CSV missing header row


I'm trying to export data from a query inside Intellij IDEA.  The results window shows the labels for each column, but when I export, this header row is always stripped out.

How can I export CSV and include the header?  The settings in CSV formatting have no effect; because this is a query (not a table export), I can't "right-click" on the table as some suggest.

Official comment

@ Peter J Nelson 

You can configure a desired behavior in settings:


@ Peter J Nelson & @Nathan Brustein 

One can create his/her own format and save it. Then it'll be available in export drop down menu:

I've had trouble with this before because I did not realize in settings that there are separate settings for .tsv files and .csv files.  You may have tried this already, but these steps work for me:

 - open settings by clicking the wrench to the left of the query results pane

 - Navigate in the menu to Database -> CSV formats

 - At the top, under "Formats", switch to "Comma-separated" (this is the part that it took me a while before I noticed it)

 - Farther down the form, find a checkbox for "First row is header", and check it

Another annoying thing I've found is that this option will always get unchecked every time I re-open DataGrip.  If anyone knows how to configure it so it stays checked, I would like to know.


Thank you @vasily chernov.  That works exactly as described.


Please sign in to leave a comment.