0

我正在使用模式爬虫来爬取 oracle 数据库(检索表/同义词元数据,包括列详细信息和外键)

INFO: 
-- generated by: SchemaCrawler 16.15.1
-- database: Oracle Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production
-- driver: Oracle JDBC driver 19.3.0.0.0
-- JVM system: AdoptOpenJDK OpenJDK 64-Bit Server VM 1.8.0_292-b10

在我的 POM 中,我包含了 oracle 插件

      <groupId>us.fatehi</groupId>
      <artifactId>schemacrawler-oracle</artifactId>
      <version>${schemacrawler.version}</version>
    </dependency>

我在 LimitOptionsBuilder 和 LoadOptions 中设置了以下内容来抓取架构:

limitOptionsBuilder.tableTypes("TABLE,VIEW,SYNONYM");
limitOptionsBuilder.includeAllSynonyms();
final SchemaCrawlerOptions options = SchemaCrawlerOptionsBuilder.newSchemaCrawlerOptions()
.withLimitOptions(limitOptionsBuilder.toOptions())
.withLoadOptions(loadOptionsBuilder.toOptions());
Catalog cat = SchemaCrawlerUtility.getCatalog(conn, options);

在目录输出中,我没有看到任何同义词。我做了一些调试,似乎发送到数据库以获取表的查询正在使用 DBA_TAB_COMMENTS,不幸的是它不包含 SYNONYM 信息。在 oracle 中,同义词存储在 ALL_SYNONYMS

SELECT  
  NULL AS TABLE_CAT,
  TABLES.OWNER AS TABLE_SCHEM,
  TABLES.TABLE_NAME AS TABLE_NAME,
  TABLES.TABLE_TYPE AS TABLE_TYPE,
  TABLES.COMMENTS AS REMARKS
FROM 
  DBA_TAB_COMMENTS TABLES
WHERE
  TABLES.OWNER NOT IN 
    ('ANONYMOUS', 'APEX_PUBLIC_USER', 'APPQOSSYS', 'BI', 'CTXSYS', 'DBSNMP', 'DIP', 
    'EXFSYS', 'FLOWS_30000', 'FLOWS_FILES', 'GSMADMIN_INTERNAL', 'IX', 'LBACSYS', 
    'MDDATA', 'MDSYS', 'MGMT_VIEW', 'OE', 'OLAPSYS', 'ORACLE_OCM', 
    'ORDPLUGINS', 'ORDSYS', 'OUTLN', 'OWBSYS', 'PM', 'SCOTT', 'SH', 
    'SI_INFORMTN_SCHEMA', 'SPATIAL_CSW_ADMIN_USR', 'SPATIAL_WFS_ADMIN_USR', 
    'SYS', 'SYSMAN', 'SYSTEM', 'TSMSYS', 'WKPROXY', 'WKSYS', 'WK_TEST', 
    'WMSYS', 'XDB', 'XS$NULL', 'RDSADMIN')  
  AND NOT REGEXP_LIKE(TABLES.OWNER, '^APEX_[0-9]{6}$')
  AND NOT REGEXP_LIKE(TABLES.OWNER, '^FLOWS_[0-9]{5,6}$')
  AND REGEXP_LIKE(TABLES.OWNER, '${schemas}')
  AND TABLES.TABLE_NAME NOT LIKE 'BIN$%'
  AND NOT REGEXP_LIKE(TABLES.TABLE_NAME, '^(SYS_IOT|MDOS|MDRS|MDRT|MDOT|MDXT)_.*$')
UNION ALL
SELECT  
  NULL AS TABLE_CAT,
  MVIEWS.OWNER AS TABLE_SCHEM,
  MVIEWS.MVIEW_NAME AS TABLE_NAME,
  'MATERIALIZED VIEW' AS TABLE_TYPE,
  MVIEWS.COMMENTS AS REMARKS
FROM 
  DBA_MVIEW_COMMENTS MVIEWS
WHERE
  MVIEWS.OWNER NOT IN 
    ('ANONYMOUS', 'APEX_PUBLIC_USER', 'APPQOSSYS', 'BI', 'CTXSYS', 'DBSNMP', 'DIP', 
    'EXFSYS', 'FLOWS_30000', 'FLOWS_FILES', 'GSMADMIN_INTERNAL', 'IX', 'LBACSYS', 
    'MDDATA', 'MDSYS', 'MGMT_VIEW', 'OE', 'OLAPSYS', 'ORACLE_OCM', 
    'ORDPLUGINS', 'ORDSYS', 'OUTLN', 'OWBSYS', 'PM', 'SCOTT', 'SH', 
    'SI_INFORMTN_SCHEMA', 'SPATIAL_CSW_ADMIN_USR', 'SPATIAL_WFS_ADMIN_USR', 
    'SYS', 'SYSMAN', 'SYSTEM', 'TSMSYS', 'WKPROXY', 'WKSYS', 'WK_TEST', 
    'WMSYS', 'XDB', 'XS$NULL', 'RDSADMIN')  
  AND NOT REGEXP_LIKE(MVIEWS.OWNER, '^APEX_[0-9]{6}$')
  AND NOT REGEXP_LIKE(MVIEWS.OWNER, '^FLOWS_[0-9]{5,6}$')
  AND REGEXP_LIKE(MVIEWS.OWNER, '${schemas}')```
4

0 回答 0