0

我可以使用 SchemaCrawler 和 MySQL5.7 检索表和列的注释,但是索引的注释失败了。这是一个例子:

1) 表定义

create table testtable(
  id bigint unsigned auto_increment,
  city_id varchar(256),
  person_id varchar(256),
  primary key(id) comment 'This is comment for the primary key',
  key idx1 (city_id, person_id) comment 'This is the comment for test index'
) comment='This is the comment for test table';

2)Java代码

// jdbc:mysql://localhost:3306/testdb?useInformationSchema=true&useUnicode=true&characterEncoding=utf8
final Connection connection = ...;
final DatabaseSpecificOverrideOptions databaseSpecificOverrideOptions =
                        SchemaCrawlerUtility.matchDatabaseSpecificOverrideOptions(connection);

final SchemaCrawler schemaCrawler = new SchemaCrawler(connection, databaseSpecificOverrideOptions);

final SchemaCrawlerOptions options = new SchemaCrawlerOptions();
options.setSchemaInfoLevel(SchemaInfoLevelBuilder.maximum());
options.setTableInclusionRule(new IncludeAll());
options.setColumnInclusionRule(new IncludeAll());

final Catalog catalog = schemaCrawler.crawl(options);
final Collection<schemacrawler.schema.Table> tables = catalog.getTables();

for (schemacrawler.schema.Table t : tables) {
    System.out.println(t.getPrimaryKey().getRemarks());
    for (schemacrawler.schema.Index index : t.getIndexes()) {
        System.out.println(index.getRemarks());
    }
}

有什么我应该调整的吗?

谢谢!

4

1 回答 1

0

抱歉,SchemaCrawler 14.16.01 中的 MySQL 不支持索引注释。请确保在类路径中包含us.fatehi:schemacrawler-mysql jar 文件

Sualeh Fatehi,SchemaCrawler

于 2017-04-05T23:12:26.760 回答