⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 databaseinformationfull.java

📁 hsqldb是100%java实现的数据库,是一个开放源代码的JAVA数据库 l 具有标准的SQL语法和JAVA接口 l HSQLDB可以自由使用和分发 l 非常简洁和快速的
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        String triggerCatalog;        String triggerSchema;        String triggerName;        String triggerType;        String triggeringEvent;        String tableCatalog;        String tableSchema;        String baseObjectType;        String tableName;        String columnName;        String referencingNames;        String whenClause;        String status;        String description;        String actionType;        String triggerBody;        // Intermediate holders        Iterator        tables;        Table           table;        HsqlArrayList[] vTrigs;        HsqlArrayList   triggerList;        TriggerDef      def;        Object[]        row;        // column number mappings        final int itrigger_cat       = 0;        final int itrigger_schem     = 1;        final int itrigger_name      = 2;        final int itrigger_type      = 3;        final int itriggering_event  = 4;        final int itable_cat         = 5;        final int itable_schem       = 6;        final int ibase_object_type  = 7;        final int itable_name        = 8;        final int icolumn_name       = 9;        final int ireferencing_names = 10;        final int iwhen_clause       = 11;        final int istatus            = 12;        final int idescription       = 13;        final int iaction_type       = 14;        final int itrigger_body      = 15;        // Initialization        tables = database.schemaManager.allTablesIterator();        // these are the only values supported, currently        actionType       = "CALL";        baseObjectType   = "TABLE";        columnName       = null;        referencingNames = "ROW";        whenClause       = null;        // Do it.        while (tables.hasNext()) {            table  = (Table) tables.next();            vTrigs = table.triggerLists;            // faster test first            if (vTrigs == null) {                continue;            }            if (!isAccessibleTable(table)) {                continue;            }            tableCatalog   = ns.getCatalogName(table);            triggerCatalog = tableCatalog;            tableSchema    = table.getSchemaName();            triggerSchema  = tableSchema;            tableName      = table.getName().name;            for (int i = 0; i < vTrigs.length; i++) {                triggerList = vTrigs[i];                if (triggerList == null) {                    continue;                }                for (int j = 0; j < triggerList.size(); j++) {                    def = (TriggerDef) triggerList.get(j);                    if (def == null) {                        continue;                    }                    triggerName = def.name.name;                    description = def.getDDL().toString();                    status      = def.valid ? "ENABLED"                                            : "DISABLED";                    triggerBody = def.triggerClassName;                    triggerType = def.when;                    if (def.forEachRow) {                        triggerType += " EACH ROW";                    }                    triggeringEvent         = def.operation;                    row                     = t.getEmptyRowData();                    row[itrigger_cat]       = triggerCatalog;                    row[itrigger_schem]     = triggerSchema;                    row[itrigger_name]      = triggerName;                    row[itrigger_type]      = triggerType;                    row[itriggering_event]  = triggeringEvent;                    row[itable_cat]         = tableCatalog;                    row[itable_schem]       = tableSchema;                    row[ibase_object_type]  = baseObjectType;                    row[itable_name]        = tableName;                    row[icolumn_name]       = columnName;                    row[ireferencing_names] = referencingNames;                    row[iwhen_clause]       = whenClause;                    row[istatus]            = status;                    row[idescription]       = description;                    row[iaction_type]       = actionType;                    row[itrigger_body]      = triggerBody;                    t.insertSys(row);                }            }        }        t.setDataReadOnly(true);        return t;    }    /**     * Retrieves a <code>Table</code> object describing the accessible     * attributes of the accessible user-defined type (UDT) objects     * defined within this database. <p>     *     * This description does not contain inherited attributes. <p>     *     * Each row is a user-defined type attributes description with the     * following columns:     *     * <pre class="SqlCodeExample">     * TYPE_CAT          VARCHAR   type catalog     * TYPE_SCHEM        VARCHAR   type schema     * TYPE_NAME         VARCHAR   type name     * ATTR_NAME         VARCHAR   attribute name     * DATA_TYPE         SMALLINT  attribute's SQL type from DITypes     * ATTR_TYPE_NAME    VARCHAR   UDT: fully qualified type name     *                            REF: fully qualified type name of target type of     *                            the reference type.     * ATTR_SIZE         INTEGER   column size.     *                            char or date types => maximum number of characters;     *                            numeric or decimal types => precision.     * DECIMAL_DIGITS    INTEGER   # of fractional digits (scale) of number type     * NUM_PREC_RADIX    INTEGER   Radix of number type     * NULLABLE          INTEGER   whether NULL is allowed     * REMARKS           VARCHAR   comment describing attribute     * ATTR_DEF          VARCHAR   default attribute value     * SQL_DATA_TYPE     INTEGER   expected value of SQL CLI SQL_DESC_TYPE in the SQLDA     * SQL_DATETIME_SUB  INTEGER   DATETIME/INTERVAL => datetime/interval subcode     * CHAR_OCTET_LENGTH INTEGER   for char types:  max bytes in column     * ORDINAL_POSITION  INTEGER   index of column in table (starting at 1)     * IS_NULLABLE       VARCHAR   "NO" => strictly no NULL values;     *                             "YES" => maybe NULL values;     *                             "" => unknown.     * SCOPE_CATALOG     VARCHAR   catalog of REF attribute scope table or NULL     * SCOPE_SCHEMA      VARCHAR   schema of REF attribute scope table or NULL     * SCOPE_TABLE       VARCHAR   name of REF attribute scope table or NULL     * SOURCE_DATA_TYPE  SMALLINT  For DISTINCT or user-generated REF DATA_TYPE:     *                            source SQL type from DITypes     *                            For other DATA_TYPE values:  NULL     * </pre>     *     * <B>Note:</B> Currently, neither the HSQLDB engine or the JDBC driver     * support UDTs, so an empty table is returned. <p>     * @return a <code>Table</code> object describing the accessible     *        attrubutes of the accessible user-defined type     *        (UDT) objects defined within this database     * @throws HsqlException if an error occurs while producing the table     */    Table SYSTEM_UDTATTRIBUTES() throws HsqlException {        Table t = sysTables[SYSTEM_UDTATTRIBUTES];        if (t == null) {            t = createBlankTable(sysTableHsqlNames[SYSTEM_UDTATTRIBUTES]);            addColumn(t, "TYPE_CAT", Types.VARCHAR);            addColumn(t, "TYPE_SCHEM", Types.VARCHAR);            addColumn(t, "TYPE_NAME", Types.VARCHAR, false);           // not null            addColumn(t, "ATTR_NAME", Types.VARCHAR, false);           // not null            addColumn(t, "DATA_TYPE", Types.SMALLINT, false);          // not null            addColumn(t, "ATTR_TYPE_NAME", Types.VARCHAR, false);      // not null            addColumn(t, "ATTR_SIZE", Types.INTEGER);            addColumn(t, "DECIMAL_DIGITS", Types.INTEGER);            addColumn(t, "NUM_PREC_RADIX", Types.INTEGER);            addColumn(t, "NULLABLE", Types.INTEGER);            addColumn(t, "REMARKS", Types.VARCHAR);            addColumn(t, "ATTR_DEF", Types.VARCHAR);            addColumn(t, "SQL_DATA_TYPE", Types.INTEGER);            addColumn(t, "SQL_DATETIME_SUB", Types.INTEGER);            addColumn(t, "CHAR_OCTET_LENGTH", Types.INTEGER);            addColumn(t, "ORDINAL_POSITION", Types.INTEGER, false);    // not null            addColumn(t, "IS_NULLABLE", Types.VARCHAR, false);         // not null            addColumn(t, "SCOPE_CATALOG", Types.VARCHAR);            addColumn(t, "SCOPE_SCHEMA", Types.VARCHAR);            addColumn(t, "SCOPE_TABLE", Types.VARCHAR);            addColumn(t, "SOURCE_DATA_TYPE", Types.SMALLINT);            t.createPrimaryKey(null);            return t;        }        t.setDataReadOnly(true);        return t;    }    /**     * Retrieves a <code>Table</code> object describing the accessible     * user-defined types defined in this database. <p>     *     * Schema-specific UDTs may have type JAVA_OBJECT, STRUCT, or DISTINCT.     *     * <P>Each row is a UDT descripion with the following columns:     * <OL>     *   <LI><B>TYPE_CAT</B> <code>VARCHAR</code> => the type's catalog     *   <LI><B>TYPE_SCHEM</B> <code>VARCHAR</code> => type's schema     *   <LI><B>TYPE_NAME</B> <code>VARCHAR</code> => type name     *   <LI><B>CLASS_NAME</B> <code>VARCHAR</code> => Java class name     *   <LI><B>DATA_TYPE</B> <code>VARCHAR</code> =>     *         type value defined in <code>DITypes</code>;     *         one of <code>JAVA_OBJECT</code>, <code>STRUCT</code>, or     *        <code>DISTINCT</code>     *   <LI><B>REMARKS</B> <code>VARCHAR</code> =>     *          explanatory comment on the type     *   <LI><B>BASE_TYPE</B><code>SMALLINT</code> =>     *          type code of the source type of a DISTINCT type or the     *          type that implements the user-generated reference type of the     *          SELF_REFERENCING_COLUMN of a structured type as defined in     *          DITypes (null if DATA_TYPE is not DISTINCT or not     *          STRUCT with REFERENCE_GENERATION = USER_DEFINED)     *     * </OL> <p>     *     * <B>Note:</B> Currently, neither the HSQLDB engine or the JDBC driver     * support UDTs, so an empty table is returned. <p>     *     * @return a <code>Table</code> object describing the accessible     *      user-defined types defined in this database     * @throws HsqlException if an error occurs while producing the table     */    Table SYSTEM_UDTS() throws HsqlException {        Table t = sysTables[SYSTEM_UDTS];        if (t == null) {            t = createBlankTable(sysTableHsqlNames[SYSTEM_UDTS]);            addColumn(t, "TYPE_CAT", Types.VARCHAR);            addColumn(t, "TYPE_SCHEM", Types.VARCHAR);            addColumn(t, "TYPE_NAME", Types.VARCHAR, false);     // not null            addColumn(t, "CLASS_NAME", Types.VARCHAR, false);    // not null            addColumn(t, "DATA_TYPE", Types.VARCHAR, false);     // not null            addColumn(t, "REMARKS", Types.VARCHAR);            addColumn(t, "BASE_TYPE", Types.SMALLINT);            t.createPrimaryKey(null);            return t;        }        t.setDataReadOnly(true);        return t;    }    /**     * Retrieves a <code>Table</code> object describing the accessible     * columns that are automatically updated when any value in a row     * is updated. <p>     *     * Each row is a version column description with the following columns: <p>     *     * <OL>     * <LI><B>SCOPE</B> <code>SMALLINT</code> => is not used     * <LI><B>COLUMN_NAME</B> <code>VARCHAR</code> => column name     * <LI><B>DATA_TYPE</B> <code>SMALLINT</code> =>     *        SQL data type from java.sql.Types     * <LI><B>TYPE_NAME</B> <code>SMALLINT</code> =>     *       Data source dependent type name     * <LI><B>COLUMN_SIZE</B> <code>INTEGER</code> => precision     * <LI><B>BUFFER_LENGTH</B> <code>INTEGER</code> =>     *        length of column value in bytes     * <LI><B>DECIMAL_DIGITS</B> <code>SMALLINT</code> => scale     * <LI><B>PSEUDO_COLUMN</B> <code>SMALLINT</code> =>     *        is this a pseudo column like an Oracle <code>ROWID</code>:<BR>     *        (as defined in <code>java.sql.DatabaseMetadata</code>)     * <UL>     *    <LI><code>versionColumnUnknown</code> - may or may not be     *        pseudo column     *    <LI><code>versionColumnNotPseudo</code> - is NOT a pseudo column     *    <LI><code>versionColumnPseudo</code> - is a pseudo column     * </UL>     * </OL> <p>     *     * <B>Note:</B> Currently, the HSQLDB engine does not support version     * columns, so an empty table is returned. <p>     *     * @return a <code>Table</code> object describing the columns     *        that are automatically updated when any value     *        in a row is updated     * @throws HsqlException if an error occurs while producing the table     */    Table SYSTEM_VERSIONCOLUMNS() throws HsqlException {        Table t = sysTables[SYSTEM_VERSIONCOLUMNS];        if (t == null) {            t = createBlankTable(sysTableHsqlNames[SYSTEM_VERSIONCOLUMNS]);            // ----------------------------------------------------------------            // required by DatabaseMetaData.getVersionColumns result set            // ----------------------------------------------------------------            addColumn(t, "SCOPE", Types.INTEGER);            addColumn(t, "COLUMN_NAME", Types.VARCHAR, false);       // not null            addColumn(t, "DATA_TYPE", Types.SMALLINT, false);        // not null            addColumn(t, "TYPE_NAME", Types.VARCHAR, false);         // not null            addColumn(t, "COLUMN_SIZE", Types.SMALLINT);            addColumn(t, "BUFFER_LENGTH", Types.INTEGER);            addColumn(t, "DECIMAL_DIGITS", Types.SMALLINT);            addColumn(t, "PSEUDO_COLUMN", Types.SMALLINT, false);    // not null            // -----------------------------------------------------------------  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -