On this page
PULL
Core command
Compatibility alias of DUMP: exports a query's results to a file or an H2 database.
Syntax
PULL <source> [TO <destination>] [AS <format>] [MODE <mode>] [OPEN]
Quick start
PULL CUSTOMER TO WORKCOPY.CUSTOMER AS H2;
Copies every row of CUSTOMER into the table CUSTOMER of the local H2 database WORKCOPY, created if needed.
Arguments
| Argument | Required | Values | Default |
|---|---|---|---|
<source> | Yes | A table name, / (the previous result), (<query>), LIB <script>, @<script> or API RESULT. | None |
TO <destination> | No. Required for AS H2. | A file name. <file>.<worksheet> for XLSX and ODS. <connection>.<table> for H2. | Named after the table or the Script; results otherwise |
AS <format> | No | CSV, TEXT, JSON, XLSX, ODS, H2, MD, HTML | The DefaultFileFormat setting |
MODE <mode> | No. XLSX, ODS and H2 only. | OVERWRITE, APPEND. H2 also: APPEND KEY(<column>) [FORCE] and MERGE KEY(<column>[, <column> ...]) | OVERWRITE |
OPEN | No. XLSX and ODS only. | Opens the file after the export | Not opened |
Examples
PULL CUSTOMER TO WORKCOPY.CUSTOMER AS H2;
PULL CUSTOMER TO WORKCOPY.CUSTOMER AS H2 MODE APPEND KEY(ID);
PULL (SELECT * FROM NEW_ORDERS) TO WORKCOPY.ORDERS AS H2 MODE APPEND;
PULL (SELECT ID, NAME FROM CUSTOMER WHERE COUNTRY = 'FR') TO REPORT.FRENCH_CUSTOMERS AS XLSX OPEN;
PULL CUSTOMER TO REPORT_CUSTOMERS AS CSV;
PULL API RESULT TO API_USERS AS JSON;
PULL (SELECT * FROM ORDERS WHERE CUSTOMER_ID = ${id}) TO WORKCOPY.ORDERS AS H2 MODE APPEND KEY(ID);
PULL CUSTOMER TO WORKCOPY.CUSTOMER AS H2 MODE MERGE KEY(ID);
Details
The same command as DUMP
PULL runs exactly like DUMP: the same sources, destinations, formats, write modes, defaults and files, and the same completion, cancellation and failure messages. Only its success message reads pulled into instead of exported to. Every existing PULL command line keeps working; new scripts use DUMP.
H2 destinations
MODE OVERWRITE, the default: the table is dropped and recreated from the result at every run.MODE APPEND KEY(<column>) [FORCE]: the table is created at the first run; every later run inserts only the rows whose key is greater than the table's current maximum, read from the table at each run. The key is a numeric, date or time column of the result. The query may use aJOIN, but not a comma separated or derivedFROM, nor any aggregation. A key that the database reports as possiblyNULLis refused;FORCEaccepts a key whose nullability the driver cannot report. An outer join can produceNULLkeys that some drivers do not report: such rows would be skipped by every later run.MODE APPENDwithoutKEY, andMODE MERGE KEY(<column>[, <column> ...]): as forDUMP.- Every successful run adds a row to the table
BROADSQL_PULL_AUDITof the destination database: the table, the query, the time, the source connection, the number of rows and the mode. - A destination connection that does not exist yet is created: an H2 database in the export folder, registered as a standalone connection of the built-in
LOCALEnvironment. Its name has at most 15 characters and no character that a file name cannot hold.
Related
- DUMP, the export command, which describes every rule
- Exporting to H2
- Export guide
Last modified in release 5.5.0.
Found something wrong or unclear on this page? Tell us, with the page address.