JDBC:使用高级表模式获取DatabaseMetadata的表列表调用方法getTables [英] JDBC: Get table list calling method getTables of DatabaseMetadata with advanced table pattern

查看:177
本文介绍了JDBC:使用高级表模式获取DatabaseMetadata的表列表调用方法getTables的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想调用DatabaseMetaData的getTables方法并获取所有名称不是以"KB"开头的表.

I want to call getTables method of DatabaseMetaData and get all tables which names are not starting with "KB".

我该怎么做? 谢谢

推荐答案

由于getTables()接受(仅)用于LIKE条件的标准SQL模式,所以我认为这是不可能的.

As getTables() accepts (only) standard SQL patterns for a LIKE condition, I don't think this is possible.

某些DBMS通过允许LIKE条件的正则表达式违反(也称为扩展")SQL标准(我认为SQL Server会这样做).

Some DBMS violate (aka "extend") the SQL standard by allowing regular expressions for a LIKE condition (I think SQL Server does this).

检查DBMS手册,LIKE支持哪种表达式.

Check the manual for your DBMS what kind of expressions LIKE supports.

如果确实支持正则表达式,则可以尝试使用^[^KB].*作为表名参数的过滤条件.但这又是非标准的,并且不适用于所有DBMS.

If it does support a regular expression you can try to use ^[^KB].* as the filter condition for the table name parameter. But again this is non-standard and won't work on all DBMS.

这篇关于JDBC:使用高级表模式获取DatabaseMetadata的表列表调用方法getTables的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆