001package org.itsallcode.jdbc.metadata;
002
003import java.sql.*;
004
005/**
006 * Description of a table.
007 * 
008 * @param tableCatalog              table catalog (may be {@code null})
009 * @param tableSchema               table schema (may be {@code null})
010 * @param tableName                 table name
011 * @param tableType                 table type. Typical types are "TABLE",
012 *                                  "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
013 *                                  "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
014 * @param remarks                   explanatory comment on the table (may be
015 *                                  {@code null})
016 * @param typeCatalog               the types catalog (may be {@code null})
017 * @param typeSchema                the types schema (may be {@code null})
018 * @param typeName                  type name (may be {@code null})
019 * @param selfReferencingColumnName name of the designated "identifier" column
020 *                                  of a typed table (may be {@code null})
021 * @param refGeneration             specifies how values in
022 *                                  SELF_REFERENCING_COL_NAME are created.
023 *                                  Values are "SYSTEM", "USER", "DERIVED". (may
024 *                                  be {@code null})
025 * @see DatabaseMetaData#getTables(String, String, String, String[])
026 */
027public record TableMetaData(String tableCatalog, String tableSchema, String tableName, String tableType,
028        String remarks, String typeCatalog, String typeSchema, String typeName, String selfReferencingColumnName,
029        String refGeneration) {
030    static TableMetaData create(final ResultSet rs) throws SQLException {
031        return new TableMetaData(
032                rs.getString("TABLE_CAT"),
033                rs.getString("TABLE_SCHEM"),
034                rs.getString("TABLE_NAME"),
035                rs.getString("TABLE_TYPE"),
036                rs.getString("REMARKS"),
037                rs.getString("TYPE_CAT"),
038                rs.getString("TYPE_SCHEM"),
039                rs.getString("TYPE_NAME"),
040                rs.getString("SELF_REFERENCING_COL_NAME"),
041                rs.getString("REF_GENERATION"));
042    }
043}