实现原理:主要是利用DatabaseMetaData.getTables(...)这个方法实现的,但是每一种数据库还存在一些差异,具体见下面详解。
一、getTables(...)方法说明
Java代码
ResultSet DatabaseMetaData.getTables(String catalog,
String schemaPattern,
String tableNamePattern,
String types[])throwsSQLException;
ResultSet DatabaseMetaData.getTables(String catalog,
String schemaPattern,
String tableNamePattern,
String types[]) throws SQLException;
catalog - 数据库目录名称,可设为null,(具体JDBC驱动的实现不一样在MySQL中指数据库名)。
schemaPattern - 方案名称的样式,可设为null,( 具体JDBC驱动的实现不一样, 在Oracle中指用户名)。
tableNamePattern - 表名称的样式,可以包含匹配符比如:"TEST%"
types - 要包括的表类型组成的列表,可设为null,表示所有的。types的常量值为:"TABLE","VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM"
各种数据库系统对Catalog和Schema的支持和实现方式是不一样的