Skip to content

ltmai/scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oracle scripts

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;

1. Generate INSERT script

  • 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.

2. Generate LOADER files

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

Windows Batch

1. env.cmd - Initialize console settings

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.

2. head.cmd - Show the first lines in file

3. line.cmd - Show specific line in file

4. which.cmd - Locate the executable

Powershell

1. Powergrep.ps1

2. ReplaceTextInFile.ps1

3. TrimTrailingSpacesInFile.ps1

4. FilterFileContentNotLike.ps1

5. ExtractRemoteHost.ps1

6. WildflyHttpConnections.ps1

About

Various scripts: PL/SQL, Batch, Powershell

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published