Here you can find the instruction on how to export data from any database to SQL file(s) in Exportizer software, either from GUI or command line.
Please note, that when choosing exporting to SQL, you do the things twice: first, export the data to SQL file(s); second, load data from the script(s) to your destination database. Therefore, this option can be less effective, especially for large datasets or when automating the data exporting.
Export Conditions
Make sure the Exportizer and the corresponding clients, ODBC drivers etc. have the same architecture (all 32-bit or all 64-bit). Please note that when working with databases through FD interface, no ODBC drivers are required; FD interface is available in Exportizer Enterprise only.
Note: If your operating system is 64-bit, you can install both Exportizer 32-bit and Exportizer 64-bit and use them independently.
Export Steps (GUI)
- Launch Exportizer.
- Register and open your source database.
- Choose a table or tables to export and/or write and execute your SQL query or queries. Note: Exporting multiple datasets at a time is available in Exportizer Enterprise only. In Exportizer Enterprise, you can export a mix of open tables and SQL query results in one export operation.
- Choose the corresponding action from Export menu or click Export button .
- Switch to the SQL Script tab.
- If you are exporting a single dataset (table or SQL query), specify a destination SQL file. When exporting multiple datasets, you have a choice:
- export data to multiple files in one destination folder, one dataset per file (default option);
- export all datasets to one file, using Folder/File drop-down list .
- Specify export parameters: target table name, statement type, target database type, file encoding and so on.
Statement type specifies the type of SQL commands to produce. The following commands are supported:
- INSERT
- BATCH INSERT (or BULK INSERT) (if supported by target database type, e.g. MySQL, Oracle, or PostgreSQL)
- UPDATE
- MERGE (the combination of INSERT and UPDATE)
- DELETE
- PostgreSQL Copy (for PostgreSQL only)
Target database type specifies the type of database where the generated SQL command will be executed. For example, SQL Server, Firebird, SQLite etc.
There is a block of options to specify initial actions. These are SQL commands which must be added before the data processing statements. For example, if you want to drop existing table and then create it again before inserting records, use Drop table and Add DDL options; if you are not sure if the target table exists, specify Add IF (NOT) EXISTS option (if supported by the target database type, e.g. PostgreSQL or SQLite). Please note that some initial actions are mutually exclusive, for example, you cannot use Empty table and Drop table options at the same time.
- Click Next.
Specify the source-to-target table and/or field mappings.
In field mappings, you create the correspondence between the source and target columns. In addition to source table columns, you can also use calculated fields specified by formulas.
In table mappings (for multi-table exporting), you create the correspondence between the source datasets (tables and/or queries) and target SQL files. You can specify target table name and target file for each exported dataset. You can also specify nested field mappings for each table pair.
You can skip this step by clicking Export instead of clicking Next. In this case table and/or field mappings will be built automatically, which may be not desirable.
- Click Next to proceed to export logs and error handling options or click Export to start the export process immediately.
Exporting Data to SQL File(s) Using Command Line
Command Line Examples
1. Exporting a table from a DBF file:
"C:\Program Files (x86)\Vitalii Levchenko\Exportizer 9\exptizer.exe" /export /ExportType=SQL /ExportMode=REPLACE+INSERT /SuppressOverwriteOrDeletePrompt /FieldMappings=ID=id;FIRST_NAME=first_name;LAST_NAME=last_name;CITY=city;COUNTRY=country /sqlSeparator=; /sqlTableName=public.customers /TargetDBType=POSTGRESQL /AddDDL /DDLAddCheckExistence /DropTable /sqlStatementType=INSERT /CommitInterval=100 /encoding=UTF-8 /TrimTrailingSpaces /LineTerminator=WINDOWS /IncludeMemo /SrcDBInterface=ado /SrcDBKind=FILE /SrcDBDriver=DBASE "/SrcDB=C:\MyData\DBF Files" /SrcTableName=customer.dbf /TrgDB=C:\MyData\customers.sql
2. Exporting a table from SQLite file (using settings you see on the image above):
"C:\Program Files (x86)\Vitalii Levchenko\Exportizer Pro 9\exptizer.exe" /export /ExportType=SQL /ExportMode=REPLACE+INSERT /SuppressOverwriteOrDeletePrompt /FieldMappings=ID=id;FIRST_NAME=first_name;LAST_NAME=last_name;CITY=city;COUNTRY=country /TrgTableDescription=Customers /sqlSeparator=; /sqlTableName=public.customer /TargetDBType=POSTGRESQL /AddDDL /DDLAddCheckExistence /DropTable /sqlStatementType=BATCHINSERT /CommitInterval=100 /encoding=UTF-8 /TrimTrailingSpaces /LineTerminator=WINDOWS /IncludeMemo /SrcDBInterface=fd /SrcDBKind=FILE /SrcDBDriver=SQLITE /SrcDB=C:\MyData\TestSQLiteDb.db /SrcSharedCache=True /SrcLockingMode=Exclusive /SrcTableName=customer /TrgDB=C:\MyData\customer.sql
3. The same as above, but /FieldMappings parameter is replaced with /FieldMappingsFile parameter:
"C:\Program Files (x86)\Vitalii Levchenko\Exportizer Pro 9\exptizer.exe" /export /ExportType=SQL /ExportMode=REPLACE+INSERT /SuppressOverwriteOrDeletePrompt /FieldMappingsFile=C:\MyData\Customer_FieldMappings.xml /TrgTableDescription=Customers /sqlSeparator=; /sqlTableName=public.customer /TargetDBType=POSTGRESQL /AddDDL /DDLAddCheckExistence /DropTable /sqlStatementType=BATCHINSERT /CommitInterval=100 /encoding=UTF-8 /TrimTrailingSpaces /LineTerminator=WINDOWS /IncludeMemo /SrcDBInterface=fd /SrcDBKind=FILE /SrcDBDriver=SQLITE /SrcDB=C:\MyData\TestSQLiteDb.db /SrcSharedCache=True /SrcLockingMode=Exclusive /SrcTableName=customer /TrgDB=C:\MyData\customer.sql
Note: Advanced users can prepare the field mapping file using text editor (from scratch or modifying existing file). Anyways, you can generate field mappings file from GUI when exporting the same dataset.
4. Exporting multiple tables from SQLite database to SQL files in Exportizer Exnterprise:
"C:\Program Files (x86)\Vitalii Levchenko\Exportizer Exnterprise 9\exptizer.exe" /export /ExportType=SQL /ExportMode=REPLACE+INSERT /SuppressOverwriteOrDeletePrompt /TableMappingsFile=C:\MyData\SQLiteToSQL_TableMappings.xml /sqlSeparator=; /TargetDBType=POSTGRESQL /AddDDL /DDLAddCheckExistence /DropTable /sqlStatementType=BATCHINSERT /CommitInterval=1000 /encoding=UTF-8 /TrimTrailingSpaces /LineTerminator=WINDOWS /IncludeMemo /SrcDBInterface=fd /SrcDBKind=FILE /SrcDBDriver=SQLITE /SrcDB=C:\MyData\TestSQLiteDb.db /SrcSharedCache=True /SrcLockingMode=Exclusive "/TrgDB=C:\MyData\SQLite to SQL"
See also
Practical Cases
- Creating Schema for a Text Table
- Exporting Data to SQL File(s)
- Exporting Large Tables
- Exporting Calculated Fields
- Exporting BLOBs to Individual Files
- Exporting to HTML Using Template
- Importing Database Files from Explorer