我正在使用 SchemaCrawler 使用以下代码获取 MySQL5.7 表的元数据:
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<Table> tables = catalog.getTables();
for (Table t : tables) {
logger.info("Table comment: {}", t.getRemarks());
}
这是测试表:
create table testtable (
id bigint comment 'key level comment',
name varchar(32) comment 'column level comment'
) comment='table level comment';
我可以获得列级评论,但我永远无法获得表级评论。
有什么我配置错误的吗?
谢谢!