【发布时间】:2018-07-26 21:28:23
【问题描述】:
我正在按如下方式创建表:
CREATE TABLE plist1 (c1 NUMERIC, c2 VARCHAR(10)) PARTITION BY
LIST (c1)
当我尝试从 Postgres 数据库中读取完整的表列表时,包括我们用于分区的主表。
有趣的是,当我使用标准 java.sql.connection 和 java.sql.DatabaseMetadata 类的独立程序时,我可以看到完整的表列表如下:
public void getTableListFromConn() throws Exception {
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection(
"jdbc:postgresql://<hostname>:5432/postgres", "<username>",
"<password>");
System.out.println("Product name is : " + con.getMetaData().getDatabaseProductName());
ResultSet rs = null;
rs = con.getMetaData().getTables(null, null, null, new String[] { "TABLE" });
int count = 0;
while (rs.next()) {
String catName = rs.getString("TABLE_CAT");
String schemaName = rs.getString("TABLE_SCHEM");
String tableName = rs.getString("TABLE_NAME");
System.out.println("Cat : " + catName + " schemaname : " + schemaName + " tableName : " + tableName);
}
System.out.println("Count is : " + count);
}
从博客https://www.javacodegeeks.com/2014/08/integrating-jooq-with-postgresql-partitioning.html我读到jooq不直接支持分区。
无论如何,我们是否可以使用 JOOQ 库获得完整的表列表。
【问题讨论】:
标签: postgresql partitioning jooq