Use this format to export data to one or more SQL scripts. The scripts contain series of SQL statements, which can be used later to insert, update, or delete the data in target database tables using the corresponding SQL tool (Database Tour or another one).
Exporting is performed by Database Tour export engine with direct file access and therefore is very fast.
Notes
- BLOB and other fields, whose data cannot be represented in SQL text, are not exported. Consider using Database export format for that.
- SQL script is an intermediary format. Using it, you export data into the target database in two steps: first, you export source data to the SQL script, and second, you run the SQL script in your target database. Consider using Database export format to export your source data directly to the target database.
The data can be exported to SQL Script format either from Database Tour (Pro) GUI or from the Database Tour Pro command line.
When exporting data from GUI, switch to SQL Script page of the Export dialog. If this page is not visible, click Favorite Export Formats button in the top-right corner of the window and make sure the corresponding format is selected.
Format Specific Options
File - when exporting data from a table or SQL query, or when exporting data from a group of tables (multi-table export), specify a file name to export data to. In case of multi-table exporting, all tables will be outputted to one target file, and some optional parameters can be specified in Table Mappings. The option is not available when exporting data to clipboard.
Folder - when exporting data from a group of tables (multi-table export), specify a folder name to export data to. Each table will be exported to a separate file in the specified folder; file names and SQL table names can be specified in Table Mappings. The option is not available when exporting data to clipboard.
Table name - specify table name to use in the generated statements. Available when exporting data from one dataset. For multi-table exporting, table names can be specified at the Table mappings step.
Statement type - specify type of SQL statements. For multi-table exporting, the value can be overridden for each individual table in Table mappings section. Allowed values:
Insert Application will create a series of INSERT statements. |
Batch Insert Application will create a series of batch INSERT statements. Batch INSERT command allows to insert multiple rows at a time. Commit interval (see below) is used as a batch size. Notes
|
Merge Application will create a series of MERGE or INSERT+UPDATE statements. It is required to specify key fields (see below) to match the rows. Notes The MERGE commands are generated only for target database types that support it (Oracle, DB2, Teradata, SQL Server); for other database types, the nearest possible solution is used (e.g. INSERT with ON CONFLICT clause for PostgreSQL); if the nearest possible solution is not known for the certain database type, the pair of UPDATE and commented INSERT commands is used. |
Update Application will create a series of UPDATE statements. It is required to specify key fields (see below) to match the rows. |
Delete Application will create a series of DELETE statements. It is required to specify key fields (see below) to match the rows. |
PostgreSQL Copy Application will create a series of COPY statements. COPY statement is a very specific kind of statements to insert multiple rows in PostgreSQL database. It is often used in SQL dumps. Please make sure your SQL application can work with such statements. |
Key fields (moved to Field mappings section) - specify matching fields to use in the ON (for MERGE statements) or WHERE (for UPDATE and DELETE statements) clause of the generated statements. This must be a name of a target field or a comma-separated list of several target field names. In Field mappings section, the key fields must be present among target fields.
Table description - specify description to be applied to the target table; currently, it can be applied to Oracle, SQL Server, PostgreSQL, and MySQL databases, and only with Add DDL option. If you specify <copy_from_source>, the application will try to use description of the source table (if any), but it requires more time to process.
Target database type - specify target database type, which lets the application know how to encode some specific data types in output file (for example, boolean, date, time, and timestamp). If the target database type is unknown, choose * Not specified *, in this case ANSI SQL standard will be used wherever possible.
Command separator - specify the separator between separate SQL statements; note, that the application always completes the separator by a line break.
Encoding - specify the encoding of the target file(s).
BOM - specify either to include BOM (byte order mark) when using Unicode encoding.
Commit interval - specify number of source records after which COMMIT statement should be added; if 0 is specified, COMMIT statement is added once after the last record in the script. Ignored if target database type does not support COMMIT statement in SQL.
Include MEMO fields - specify either to include contents of MEMO / CLOB fields in target or not; in the latter case, a constant describing the field type will be used instead of the field contents. MEMO / CLOB fields can store large amount of text, so including them for this target format can significantly affect the results, especially if the text contains line or column breaks or other special characters.
Trim trailing spaces - specify either to trim trailing spaces and control characters in target or not. Applicable for char and varchar data only. Using this option allows to remove useless data and thus reduce the output volume, improve the target look for some destination formats etc.
Initial actions - actions (commands) to add before DML statements.
Empty table - specify either to add TRUNCATE (if supported by target database) or DELETE statement into the output script before insert statements. Cannot be used together with Drop table and Add DDL options.
Drop table - specify either to add DROP TABLE statement into the output script before insert statements. Cannot be used together with Empty table option.
Add DDL - specify either to add DDL statement (CREATE TABLE...) into the output script before insert statements. Cannot be used together with Empty table option.
Add IF (NOT) EXISTS - specify either to include IF NOT EXISTS clause in CREATE TABLE statement, and IF EXISTS clause in DROP TABLE statement. It is supported only for PostgreSQL, MySQL, and SQLite databases. Must be used together with Add DDL and/or Drop table options.
Line break - specify line break style; if you choose Windows, then each line in the file will be terminated by carriage return and new line character (CR+LF); if you choose Mac, a carriage return (CR) will be used to separate lines; otherwise, Unix style will be used (LF).
Export mode
Specify export mode:
REPLACE+INSERT Target is created and filled with incoming rows; if target already exists, it is overwritten. |
CREATE_OR_REPLACE Blank target (using appropriate structure) is created; if target already exists, it is overwritten. |
APPEND Target is appended with incoming rows; if target does not exist, it is created. |
Note: For multi-table exporting, the value can be overridden for each individual table in Table mappings section.
Record range
Specify range of source records to be exported:
Full table - all records are exported.
Selected records only - only selected records are exported. To select rows, click the corresponding button and then select needed rows using Shift, Ctrl and arrow keys.
From current record to the last one - all data between current and the last records are exported.
Limit the record count to - specify a maximum number of records to be exported. If this option is not specified or it is less then 1, all records from the specified record range will be exported. If you want just create a file (table) without data exporting, use the corresponding Export mode instead.
Column range
Specify range of source columns to be exported:
All columns - all columns (including columns, which were temporary hidden by user) are exported.
Selected column only - only selected (current) column is exported.
Visible columns - only visible columns are exported.
Other options
Ask before overwrite or empty existing target - specify either to ask the user to overwrite existing target for REPLACE+INSERT and CREATE_OR_REPLACE export modes. The option is not available when exporting data to clipboard.
See also