0
我可以使用SchemaCrawler和MySQL5.7檢索表和列的註釋,但是失敗了索引的註釋。這是一個例子:使用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());
}
}
有什麼,我應該調整?
謝謝!
感謝您的澄清。期待看到新版本。 – user1040933
請使用SchemaCrawler 14.06.01 –