In oder to test the scripts you may use the built-in schema tiger
. This schema is locked by
default, but can be unlocked by user SYS AS SYSDBA as follows:
SQL> ALTER USER scott IDENTIFIED BY tiger ACCOUNT UNLOCK;
- generateInsertScripts.cmd
- generateInsertScripts.sql
- TrimTrailingSpacesInFile.ps1
- INSERTscript.sql
The script oracle\generate_insert_scripts\generateInsertScript.sql
contains the code and its
example use. In general the syntax is createInsertScript(tableName, customWhereClause, customOrderByClause)
where customWhereClause
and customOrderByClause
are optional. By default INSERT statements are
generated for all rows; data is sorted by primary key or first column if no primary key is defined.
You may use custom WHERE clause to filter target data and custom ORDER BY clause to change the
oder of INSERT statements. For example:
BEGIN
createInsertScript(tableNameIn => 'emp', whereClause => 'deptno=10', orderClause => 'ename');
END;
/
The batch file generateInsertScript.cmd
is only a wrapper to run the SQL script and trim trailing
white spaces in output file.
The script oracle\generate_oracle_loader_files\generateLoaderScript.sql
contains the SQL code.
The batch file generateLoaderScripts.cmd
is a wrapper to run this script and also provides some
examples. For convenience, you may want to edit the batch file to change the table names. The output
files are generated in output
folder. The following should be adapted to suit your need:
:: Change Oracle connection string here
:: Syntax: username/password@SID
SET dbconn=scott/tiger@ORACLE
:: Change table names or add new tables here
sqlplus %dbconn% @generateLoaderScript dept
sqlplus %dbconn% @generateLoaderScript emp
sqlplus %dbconn% @generateLoaderScript bonus
sqlplus %dbconn% @generateLoaderScript salgrade
This script is an example of initializing Windows console at startup. It is a place to set environment variables, change the default command prompt, define doskey macros, and so on.