• Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
  • 1. Help
    sc

    2. Help on a command
    sc -help -command=graph

    3. Plain text list of tables
    sc -host=192.168.153.139 -user=sa -password=sualeh -database=AdventureWorks -schemas=AdventureWorks\.(?:(?!sys).)* -infolevel=minimum -procedures= -command=list

    4. Plain text list of Product tables
    sc -host=192.168.153.139 -user=sa -password=sualeh -database=AdventureWorks -schemas=AdventureWorks\.(?:(?!sys).)* -infolevel=minimum -procedures= -tables=.*\..*\.Product.* -command=list

    5. Plain text, standard schema
    sc -host=192.168.153.139 -user=sa -password=sualeh -database=AdventureWorks -schemas=AdventureWorks\.(?:(?!sys).)* -infolevel=standard -procedures= -tables=.*\..*\.Product.* -command=schema

    6. HTML standard schema
    sc -host=192.168.153.139 -user=sa -password=sualeh -database=AdventureWorks -schemas=AdventureWorks\.(?:(?!sys).)* -infolevel=standard -procedures= -tables=.*\..*\.Product.* -command=schema -outputformat=html > ProductTables.html

    7. Plain text, detailed
    sc -host=192.168.153.139 -user=sa -password=sualeh -database=AdventureWorks -schemas=AdventureWorks.Production -procedures= -tables=AdventureWorks.Production.WorkOrder -noinfo -infolevel=lint -command=details

    8. Detailed plain text for a view
    sc -host=192.168.153.139 -user=sa -password=sualeh -database=AdventureWorks -schemas=AdventureWorks.Sales -procedures= -tables=AdventureWorks.Sales.vIndividualCustomer -noinfo -infolevel=lint -command=details

    9. Counts
    sc -host=192.168.153.139 -user=sa -password=sualeh -database=AdventureWorks -schemas=AdventureWorks\.(?:(?!sys).)* -infolevel=minimum -procedures= -tables=.*\..*\.Product.* -command=count

    10. Dumps
    sc -host=192.168.153.139 -user=sa -password=sualeh -database=AdventureWorks -schemas=AdventureWorks.Production -infolevel=standard -procedures= -tables=AdventureWorks.Production.ProductCategory -command=dump

    11. Grep example
    sc -host=192.168.153.139 -user=sa -password=sualeh -database=AdventureWorks -schemas=AdventureWorks\.(?:(?!sys).)* -infolevel=standard -procedures= -grepcolumns=.*\..*ProductID -command=schema

    12. Procedures, detailed
    sc -host=192.168.153.139 -user=sa -password=sualeh -database=AdventureWorks -schemas=AdventureWorks\.HumanResources -noinfo -infolevel=maximum -tables= -command=details

    13. Diagram
    sc -host=192.168.153.139 -user=sa -password=sualeh -database=AdventureWorks -schemas=AdventureWorks\.(?:(?!sys).)* -infolevel=lint -table_types=TABLE -procedures= -grepcolumns=.*\..*CustomerID -command=graph -outputformat=pdf

    14. Javascript
    sc -host=192.168.153.139 -user=sa -password=sualeh -database=AdventureWorks -schemas=AdventureWorks\.(?:(?!sys).)* -tables=.*\..*\.Product.* -infolevel=standard -procedures= -command=script -outputformat=tables.js
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
6,484
On Slideshare
0
From Embeds
0
Number of Embeds
4

Actions

Shares
Downloads
17
Comments
1
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. SchemaCrawler
    Sualeh Fatehi
  • 2. What is SchemaCrawler?
    Schema discovery tool
    “grep” through your schema
    Create schema diagrams
    Lint your schema
    Infer table relationships
    Interact with your database using JavaScript
    Write templates to generate output
    http://www.schemacrawler.com
    2
  • 3. About
    Project started about 8 years ago
    Continuously maintained
    Written in pure Java and pure JDBC
    Open source and free
    Business-friendly LGPL license
    Database and operating system independent
    Command-line tool
    Maven and ant support
    Provides a Java API for database metadata
    http://www.schemacrawler.com
    3
  • 4. Installation
    Download and unzip
    A large number of examples provided
    Several database-specific versions available
    Open source JDBC drivers bundled where available
    Oracle and DB2 drivers need to be provided
    GraphViz needed for graphing
    http://www.schemacrawler.com
    4
  • 5. Problems with JDBC Metadata
    JDBC Metadata
    ResultSet
    1, “YES”, or “TRUE”
    Types
    • TABLE_TYPE: string
    • 6. PROCEDURE_TYPE: integer
    • 7. COLUMN_TYPE: does not exist SQL_DATA_TYPE: unusedDATA_TYPE: yes!
    SchemaCrawler
    POJO
    boolean value
    getType() returns an enum
    http://www.schemacrawler.com
    5
    http://www.devx.com/Java/Article/32443/1954
  • 8. Code Example
    finalDatabase database =
    SchemaCrawlerUtility.getDatabase(connection, options);
    for(final Schema schema: database.getSchemas())
    {
    System.out.println(schema);
    for(final Table table: schema.getTables())
    {
    System.out.println("o--> " + table);
    for(final Column column: table.getColumns())
    {
    System.out.println(" o--> " + column +
    " (" + column.getType() + ")");
    }
    }
    }
    http://www.schemacrawler.com
    6
  • 9. Command-line Basics
    scfor help
    Connection parameters - user name and password, and one of
    • Connection URL
    • 10. Host and port
    Information level
    • Determines amount of schema information retrieved
    • 11. Determines time taken to crawl
    • 12. Schemas
    • 13. SchemaCrawler command
    http://www.schemacrawler.com
    7
  • 14. Commands and Output
    Plain text and HTML formats are available
    All text formats are designed to be diff-ed
    Commands
    http://www.schemacrawler.com
    8
  • 21. Examples
    Help and options overview
    Basic schema output, in text and HTML
    Count and dump
    grep
    Triggers
    Stored procedures
    Diagram
    Lint
    http://www.schemacrawler.com
    9
  • 22. Questions?
    http://www.schemacrawler.com
    10