Version 3.0.3. It's a fairly large result-set, around 3 million rows.
-
What kind of database is it? Some databases already have abilities to write to output files. – FrustratedWithFormsDesigner Feb 22 '10 at 20:48
-
i know i can do it using the cmdline, but id like to be able to do it from the graphical interface – alex Feb 22 '10 at 20:51
5 Answers
Martin pretty much has this right.
The TL/DR version is that you need the "SQLScripts" plugin (which is one of the "standard' plugins), and then you can select these menu options: Session
> Scripts
> Store Result of SQL in File
I'm looking at version 3.4. I don't know when this feature was introduced but you may need to upgrade if you don't have and cannot install the SQLScripts plugin.
Instructions for installing a new plugin can be found at: http://squirrel-sql.sourceforge.net/user-manual/quick_start.html#plugins
But if you're performing a fresh install of Squirrel you can simply select the "SQLScripts" plugin during the installation.
Here's the long version:
Run the query
Connect to the database. Click on the
SQL
tab. Enter your query. Hit the run button (orCtrl-Enter
).You should see the first 100 rows or so in the results area in the bottom half of the pane (depending upon how you've configured the
Limit Rows
option).Export the full results
Open the
Session
menu. Select theScripts
item (nearly at the bottom of this long menu). SelectStore Result of SQL in File
.This opens a dialog box where you can configure your export. Make sure you check
Export the complete result set
to get everything.
I haven't tried this with a 3 million row result set, but I have noticed that Squirrel seems to stream the data to disk (rather than reading it all into memory before writing), so I don't see any reason why it wouldn't work with an arbitrarily large file.
Note that you can export directly to a file by using Ctrl-T
to invoke the tools popup and selecting sql2file
.

- 2,226
- 22
- 21
-
Just a quick update: Yesterday I happen to have used this feature to export about 8 million rows from a data warehouse schema. Squirrel/SQLScripts worked like a champ. – Rod Oct 18 '12 at 13:10
-
When I try "Store Result of SQL in File" it returns "Method not supported" – Andrew Ehrlich Apr 23 '14 at 23:50
-
I have found a way to do this, there is a nice support for this in Squirrel. Run the SQL select (the 100 row limit will be ignored by the exporter, don't worry). Then, in the main menu, choose Session, Scripts, Store Result of SQL in File. This functionality may not be present by default, it may be present in some standard plugin (but not installed by default). I don't know which plugin though.

- 3,088
- 28
- 39
I also wanted to export results of SQL query to CSV file using SquirrelSQL. However according to changes file it seems that this functionality is not supported even in SquirrelSql 3.3.0.
So far I was able to export only data shown in 'result table' of SQL query by right click on the table > Export to CSV. The table size is by default 100 rows and so is the CSV export. You may change the table size in Session Properties > SQL > Limit rows. E.g. change the size to 10000 and your export will also contain 10000 rows. The question is, how will SquirrelSql deal with really big result sets (millions of rows)...

- 2,486
- 2
- 28
- 47
Run from your GUI:
COPY (SELECT * FROM some_table) TO '/some/path/some_table.csv' WITH CSV HEADER

- 7,816
- 2
- 33
- 49
-
2Note that this will run the copy process on the *server*. So if it's a remote server, the file will be dumped on that server, and not your local machine. Likewise, you need to make sure that the server process has write permissions there. You can use \copy instead of copy to get it on the client side if you use psql - not sure if squirrel has anything like it. – Magnus Hagander Feb 23 '10 at 08:09
Using Squirrel 3.5.0 The "Store SQL result as file" is great if you only have a simple Select query. A more complex one with parameters wont work. Even trying to export a result of 600,000+ rows to a CSV file can also fail.