【问题标题】:schemacrawler returning tables from all available databasesschemacrawler 从所有可用数据库返回表
【发布时间】:2015-03-18 09:32:37
【问题描述】:

我正在使用 schemacrawler 从 mysql 数据库中获取表列表。问题是,结果包括来自所有可用数据库的表。它正在从给定的数据库名称(DataSource)之外获取表。

<bean id="schemaCrawlerOptions" class="schemacrawler.schemacrawler.SchemaCrawlerOptions">
    <property name="sequenceInclusionRule">
        <bean class="schemacrawler.schemacrawler.IncludeAll" />
    </property>
    <property name="tableTypes">
        <set>
            <value>TABLE</value>
            <!-- <value>VIEW</value> -->
        </set>
    </property>
    <property name="schemaInfoLevel">
        <bean factory-method="standard"
            class="schemacrawler.schemacrawler.SchemaInfoLevel" />
    </property>
</bean>
<bean id="executableForSchema" class="schemacrawler.tools.text.schema.SchemaTextExecutable"> <!-- This is the final class we need to execute schemacrawler -->
    <constructor-arg value="schema" />
    <property name="schemaCrawlerOptions" ref="schemaCrawlerOptions" />
    <property name="schemaTextOptions">
        <bean class="schemacrawler.tools.text.schema.SchemaTextOptions">
            <property name="showOrdinalNumbers" value="false" />
            <property name="showStandardColumnTypeNames" value="false" />
            <property name="hidePrimaryKeyNames" value="true" />
            <property name="hideIndexNames" value="true" />
            <property name="hideForeignKeyNames" value="true" />
            <property name="hideConstraintNames" value="true" />
            <property name="noInfo" value="false" />
        </bean>
    </property>
    <property name="outputOptions" ref="outputOptions" />
</bean>

这是我的弹簧上下文。

【问题讨论】:

    标签: schemacrawler


    【解决方案1】:

    Khader,这种行为实际上取决于您的数据库的权限,而不是您使用的数据源。如果您的数据库用户有权访问某个表,SchemaCrawler 将报告它,而不管它属于哪个模式。因此,最好使用访问受限的数据库用户,而不是系统管理员帐户。

    但是,您可以让 SchemaCrawler 限制它将报告的架构和表。您需要在 schemaCrawlerOptions 上设置 schemaInclusionRule 和可选的 tableInclusionRule。

    换句话说,请适当设置:

    <bean id="schemaCrawlerOptions" class="schemacrawler.schemacrawler.SchemaCrawlerOptions"> <property name="schemaInclusionRule"> ... ... <!-- Set an appropriate value here --> </property> ... ... ... </bean>

    苏莱赫。

    【讨论】:

      猜你喜欢
      • 2023-04-03
      • 1970-01-01
      • 2017-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-25
      相关资源
      最近更新 更多