基于JDBC的数据库结构提取工具,SchemaCrawler 9.0 发布

jopen 12年前
   <p><a href="/misc/goto?guid=4958189000824288851" target="_blank">SchemaCrawler</a>提供一组用于增强标准JDBC Metadata的API.SchemaCrawler还包含一个命令行工具能够将数据库结构和数据以一种易读的形式输出.<br /> </p>   <pre class="brush:java; toolbar: true; auto-links: false;">final SchemaCrawlerOptions options = new SchemaCrawlerOptions();  // Set what details are required in the schema - this affects the  // time taken to crawl the schema  options.setSchemaInfoLevel(SchemaInfoLevel.standard());    final Database database = SchemaCrawlerUtility.getDatabase(connection, options);  for (final Schema schema: database.getSchemas())  {    System.out.println(schema);    for (final Table table: database.getTables(schema))    {      System.out.print("o--> " + table);      for (final Column column: table.getColumns())      {        System.out.println("     o--> " + column);      }    }  }</pre>   <br /> SchemaCrawler 9.0 发布,该版本的 API 进行了修改,所有 API 的调用返回集合而不是数组,Schemas 也不再是容器,使用标签来作为数据库对象,允许直接在命令行上查询,-procedures 改为 -routines 等等。   <p></p>    <p> </p>