Search code examples
importexportdbeaver

Limit number of exported / imported rows in DBeaver


is there a way to limit the number of rows while exporting or imported data in DBeaver?

In my case I have a remote DB2 and I need to import SOME rows of a specific table into a local MySQL DB that I have.

Is there a way to do that?

Thanks


Solution

  • Limiting the number of rows being exported only makes sense if the export wizard knows what rows (e.g. order) to export. Therefore it only makes sense to export the resultset of a query, as opposed to export the actual table with a limiting factor.

    This is how you can do this in DBeaver:

    1. Issue a query like SELECT * FROM my_table ORDER BY mycolumn LIMIT n.
    2. Replace n with any integer you like obviously. You may also add DESC after mycolumn, if only the most recent rows make sense to you.
    3. Run the query.
    4. In the pane with the resultset, locate the button tooltipped "Export result set to fil or another table". It looks like a tray with an upward arrow. In DBeaver 7.2.2, it is just left of the split number and cog buttons.
    5. Run that wizard, selecting "SQL" target type (Export to SQL INSERT statements)
    6. Click Next, and configure any other export preferences (you may leave default too).
    7. The file being exported should content you.