Last active
January 22, 2019 13:30
-
-
Save djangofan/9997619 to your computer and use it in GitHub Desktop.
Example of using schemacrawler from the command line with Oracle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO off | |
SETLOCAL ENABLEDELAYEDEXPANSION | |
SET TITLE=Schema crawler | |
TITLE %TITLE% | |
ECHO.&ECHO. | |
:: FORMAT can be csv or html | |
SET FORMAT=html | |
SET INPUTFILE=table.names | |
SET USER=user | |
SET PW=myp@ssword | |
SET HO=tools.domain.com | |
SET PO=1521 | |
SET SC=TOOLS | |
ECHO ############################################################# | |
ECHO ## Connecting to Oracle at '%US%@%HO%:%PO%/%SC%' | |
ECHO ############################################################# | |
FOR /F "skip=1 tokens=2-4 delims=(-)" %%a IN ('"echo.|date"') DO ( | |
FOR /F "tokens=1-3 delims=/.- " %%A IN ("%DATE:* =%") DO ( | |
SET %%a=%%A&SET %%b=%%B&SET %%c=%%C)) | |
SET /A "yy=10000%yy% %%10000,mm=100%mm% %% 100,dd=100%dd% %% 100" | |
FOR /F "tokens=1-4 delims=:. " %%A IN ("%time: =0%") DO @SET UNIQUE=%yy%%mm%%dd%-%%A%%B | |
IF NOT EXIST snapshot_%UNIQUE% ( | |
ECHO Creating snapshot in directory ^"snapshot_%UNIQUE%^". | |
MKDIR snapshot_%UNIQUE% | |
) | |
:: Loop through input file | |
FOR /F "tokens=*" %%A IN (%INPUTFILE%) DO ( | |
ECHO Processing table '%%A' ... | |
CALL :SNAPSHOT %%A | |
) | |
GOTO :END | |
:SNAPSHOT table | |
java.exe -classpath lib/*;. schemacrawler.tools.oracle.Main ^"-command=SELECT * FROM %1^" -infolevel=minimum^ | |
-database=%SC% -user=%USER% -password=%PW% -schemas=%SC% -port=%PO% -host=%HO% -table_types=TABLE -sortcolumns=true^ | |
-outputformat=%FORMAT% -outputfile=snapshot_%UNIQUE%\%SC%.%1.%FORMAT% -g=schemacrawler.config.properties | |
EXIT /B 0 | |
:END | |
ECHO Finished processing '%INPUTFILE%' . Closing in 20 seconds... | |
ECHO. | |
FOR /l %%a IN (20,-1,1) DO (TITLE %TITLE% -- closing IN %%as&ping -n 2 -w 1 127.0.0.1>nul) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --=----=----=----=----=----=----=----=----=----=----=----=----=----=----=----= | |
# ------------------------------- SchemaCrawler -------------------------------- | |
# --=----=----=----=----=----=----=----=----=----=----=----=----=----=----=----= | |
# SchemaCrawler is a platform (both operating system and database system) | |
# independent command-line tool to output your database schema and data in a | |
# readable form. The output is designed to be diff-ed with previous versions of | |
# your database schema. | |
# --=----=----=----=----=----=----=----=----=----=----=----=----=----=----=----= | |
# SchemaCrawler Options | |
# --=----=----=----=----=----=----=----=----=----=----=----=----=----=----=----= | |
# Log level - may be one of: | |
# OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL | |
schemacrawler.log_level=ALL | |
# Filtering Options | |
# ------------------------------------------------------------------------------ | |
# Regular expression table and column name pattern to filter table | |
# and column names | |
# Column regular expression to match fully qualified column names, | |
# in the form "SCHEMANAME.TABLENAME.COLUMNNAME" | |
# Default: .* for include, <none> for exclude | |
schemacrawler.table.pattern.include=.* | |
schemacrawler.table.pattern.exclude= | |
schemacrawler.column.pattern.include=.* | |
schemacrawler.column.pattern.exclude= | |
# Regular expression procedure and procedure parameter name pattern to | |
# procedure and procedure parameter names | |
# Default: .* for include, <none> for exclude | |
schemacrawler.procedure.pattern.include=.* | |
schemacrawler.procedure.pattern.exclude= | |
schemacrawler.procedure.inout.pattern.include=.* | |
schemacrawler.procedure.inout.pattern.exclude= | |
# Grep Options | |
# ------------------------------------------------------------------------------ | |
schemacrawler.grep.column.pattern.exclude= | |
schemacrawler.grep.column.pattern.include=.* | |
schemacrawler.grep.procedure.inout.pattern.exclude= | |
schemacrawler.grep.procedure.inout.pattern.include=.* | |
schemacrawler.grep.invert-match=false | |
# Sorting Options | |
# ------------------------------------------------------------------------------ | |
# Sort orders for objects that are not sorted by name by default | |
schemacrawler.format.sort_alphabetically.table_columns=false | |
schemacrawler.format.sort_alphabetically.table_foreignkeys=false | |
schemacrawler.format.sort_alphabetically.table_indices=false | |
schemacrawler.format.sort_alphabetically.procedure_columns=false | |
# --=----=----=----=----=----=----=----=----=----=----=----=----=----=----=----= | |
# Text Formatting Options | |
# --=----=----=----=----=----=----=----=----=----=----=----=----=----=----=----= | |
# Shows all object names with the catalog and schema names, for easier comparison | |
# across different schemas | |
# Default: false | |
schemacrawler.format.show_unqualified_names=false | |
# Shows standard column names instead of database specific column names | |
# Default: false | |
schemacrawler.format.show_standard_column_type_names=false | |
# Shows ordinal numbers for columns | |
# Default: false | |
schemacrawler.format.show_ordinal_numbers=false | |
# If foreign key names, constraint names, trigger names, | |
# specific names for procedures, or index and primary key names | |
# are not explicitly provided while creating a schema, most | |
# database systems assign default names. These names can show | |
# up as spurious diffs in SchemaCrawler output. | |
# | |
# All of these are hidden with the -portablenames | |
# command-line option. | |
# | |
# Hides foreign key names, constraint names, trigger names, | |
# specific names for procedures, index and primary key names | |
# Default: false | |
schemacrawler.format.hide_primarykey_names=false | |
schemacrawler.format.hide_foreignkey_names=false | |
schemacrawler.format.hide_index_names=false | |
schemacrawler.format.hide_trigger_names=false | |
schemacrawler.format.hide_routine_specific_names=false | |
schemacrawler.format.hide_constraint_names=false | |
# Encoding of input files, such as Apache Velocity temaplates | |
# Default: UTF-8 | |
schemacrawler.encoding.input=UTF-8 | |
# Encoding of SchemaCrawler output files | |
# Default: UTF-8 | |
schemacrawler.encoding.output=UTF-8 | |
# --=----=----=----=----=----=----=----=----=----=----=----=----=----=----=----= | |
# Data Output Options | |
# --=----=----=----=----=----=----=----=----=----=----=----=----=----=----=----= | |
# Whether to merge rows that differ only in the last column | |
# Default: false | |
schemacrawler.data.merge_rows=false | |
# Whether to show data from CLOB and BLOB objects | |
# Default: false | |
schemacrawler.data.show_lobs=false | |
# --=----=----=----=----=----=----=----=----=----=----=----=----=----=----=----= | |
# Queries | |
# --=----=----=----=----=----=----=----=----=----=----=----=----=----=----=----= | |
oracle.tables=SELECT * FROM INFORMATION_SCHEMA.SYSTEM_TABLES | |
tables.select=SELECT ${columns} FROM ${table} ORDER BY ${columns} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TABLE1 | |
TABLE2 | |
TABLE3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment