121

Normally I use Dbeaver for windows and always export my result set like this:

  • Run my query --> select the result --> export the result set --> select export to clipboard --> done

This step by step puts my result set in my clipboard and I can paste it wherever I want to work with it.

The problem is that now I am using dbeaver for mac and this guide is not working. I can go on until the moment that I select my result set like in the image below:

exporting data set

But once I go further in the process, in the last step I get: no query

Note that in "source" it was suppose to show the query that originated the result set, but instead it says just "select.

As a result it does't select my result or anything (besides being "successful").

Normally my query would show up there automatically and I couldn't find any option that corrects this problem in the menus.

kenorb
  • 155,785
  • 88
  • 678
  • 743
Rafael Meirelles
  • 1,323
  • 2
  • 8
  • 10
  • After some tests I realized that it is sourcing just the first line of the query. Since it contains only "Select" that is all dbeaver is exporting. Now I have to understand why this is happening – Rafael Meirelles Apr 10 '17 at 19:34

4 Answers4

181

You don't need to use the clipboard, you can export directly the whole resultset (not just what you see) to a file :

  1. Execute your query
  2. Right click any anywhere in the results
  3. click "Export resultset..." to open the export wizard
  4. Choose the format you want (CSV according to your question)
  5. Review the settings in the next panes when clicking "Next".
  6. Set the folder where the file will be created, and "Finish"

The export runs in the background, a popup will appear when it's done.


In newer versions of DBeaver you can just :

  1. right click the SQL of the query you want to export
  2. Execute > Export from query
  3. Choose the format you want (CSV according to your question)
  4. Review the settings in the next panes when clicking "Next".
  5. Set the folder where the file will be created, and "Finish"

The export runs in the background, a popup will appear when it's done.

Compared to the previous way of doing exports, this saves you step 1 (executing the query) which can be handy with time/resource intensive queries.

Sébastien Nussbaumer
  • 6,202
  • 5
  • 40
  • 58
  • 1
    The wording of the subsequent options are strange, but leaving them alone seems to do what I wanted: copy a csv to a folder. If someone has documentation on the options, that would be a friendly thing to post here. (this link is out of date:https://github.com/dbeaver/dbeaver/wiki/Data-transfer) – geneorama Jan 15 '19 at 23:41
  • This works perfectly. I have a script file with 2500+ queries that I want to send to the same csv file. I can't use a union statement between the queries as that I get data type mismatch errors when I do. Is there a way to do this with a sql/script file? Thanks in advanced. – TheL0grus Jun 29 '22 at 15:46
  • I think you should solve the problem with the union (casting to a common datatype for the column that are not of the same type) – Sébastien Nussbaumer Jul 05 '22 at 06:31
8

The problem was the box "open new connection" that was checked. So I couldn't use my temporary table.

Rafael Meirelles
  • 1,323
  • 2
  • 8
  • 10
8

In version 21.0 / Release date march 1, 2021

  1. right click the SQL of the query you want to export
  2. Export data
  3. From query Choose the format you want (CSV according to your question)
  4. Review the settings in the next panes when clicking "Next".
  5. Set the folder where the file will be created, and "Finish"
Consule
  • 1,059
  • 12
  • 12
0

Is there a reason you couldn't select your results and right click and choose Advanced Copy -> Advanced Copy? I'm on a Mac and this is how I always copy results to the clipboard for pasting.

Kyle
  • 415
  • 1
  • 6
  • 11
  • 3
    What if the result set is so large that the result view can't display all the records? – Aetherus Aug 07 '17 at 02:56
  • 1
    Do you get an out of memory exception? If you have a result set that large, copying it to the clipboard isn't a good idea and I'd suggest exporting it to CSV. When you export a result set, DBeaver exports the entire result of the query that was executed to populate the result set viewer, not just what is shown. – Kyle Aug 09 '17 at 14:48
  • 3
    It's only about 40,000 records with 5 columns each. The RAM is enough to hold the data. However, DBeaver only shows 200 records by default. If I want all the data, I had to scroll down over and over again and that's annoying. – Aetherus Aug 10 '17 at 08:06
  • I do not think it is an elegant solution. – Harper Koo Nov 03 '17 at 08:40
  • @HarperKoo re-running the whole query for the purpose of the export (after having already run the query to display the results) is not exactly elegant either. – Jivan Apr 21 '20 at 17:21