开发者

JDBC: Get table list calling method getTables of DatabaseMetadata with advanced table pattern

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

How can I do this?开发者_运维技巧 Thanks


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

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

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

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜