📄 databaseinformationmain.java
字号:
row[ifk_column_name] = fkColumnName; row[ikey_seq] = keySequence; row[iupdate_rule] = updateRule; row[idelete_rule] = deleteRule; row[ifk_name] = fkName; row[ipk_name] = pkName; row[ideferrability] = deferrability; t.insertSys(row); } } t.setDataReadOnly(true); return t; } /** * Retrieves a <code>Table</code> object describing the visible * <code>Index</code> objects for each accessible table defined * within this database.<p> * * Each row is an index column description with the following * columns: <p> * * <pre class="SqlCodeExample"> * TABLE_CAT VARCHAR table's catalog * TABLE_SCHEM VARCHAR simple name of table's schema * TABLE_NAME VARCHAR simple name of the table using the index * NON_UNIQUE BOOLEAN can index values be non-unique? * INDEX_QUALIFIER VARCHAR catalog in which the index is defined * INDEX_NAME VARCHAR simple name of the index * TYPE SMALLINT index type: { Clustered | Hashed | Other } * ORDINAL_POSITION SMALLINT column sequence number within index * COLUMN_NAME VARCHAR simple column name * ASC_OR_DESC VARCHAR col. sort sequence: {"A" (Asc) | "D" (Desc)} * CARDINALITY INTEGER # of unique values in index (not implemented) * PAGES INTEGER index page use (not implemented) * FILTER_CONDITION VARCHAR filter condition, if any (not implemented) * // HSQLDB-extension * ROW_CARDINALITY INTEGER total # of rows in index (not implemented) * </pre> <p> * * @return a <code>Table</code> object describing the visible * <code>Index</code> objects for each accessible * table defined within this database. * @throws HsqlException if an error occurs while producing the table */ final Table SYSTEM_INDEXINFO() throws HsqlException { Table t = sysTables[SYSTEM_INDEXINFO]; if (t == null) { t = createBlankTable(sysTableHsqlNames[SYSTEM_INDEXINFO]); // JDBC addColumn(t, "TABLE_CAT", Types.VARCHAR); addColumn(t, "TABLE_SCHEM", Types.VARCHAR); addColumn(t, "TABLE_NAME", Types.VARCHAR, false); // NOT NULL addColumn(t, "NON_UNIQUE", Types.BOOLEAN, false); // NOT NULL addColumn(t, "INDEX_QUALIFIER", Types.VARCHAR); addColumn(t, "INDEX_NAME", Types.VARCHAR); addColumn(t, "TYPE", Types.SMALLINT, false); // NOT NULL addColumn(t, "ORDINAL_POSITION", Types.SMALLINT, false); // NOT NULL addColumn(t, "COLUMN_NAME", Types.VARCHAR); addColumn(t, "ASC_OR_DESC", Types.VARCHAR, 1, true); addColumn(t, "CARDINALITY", Types.INTEGER); addColumn(t, "PAGES", Types.INTEGER); addColumn(t, "FILTER_CONDITION", Types.VARCHAR); // HSQLDB extension addColumn(t, "ROW_CARDINALITY", Types.INTEGER); // order: NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION. // added for unique: INDEX_QUALIFIER, TABLE_NAME // false PK, as INDEX_QUALIFIER may be null t.createPrimaryKey(null, new int[] { 3, 6, 5, 7, 4, 2 }, false); return t; } // calculated column values String tableCatalog; String tableSchema; String tableName; Boolean nonUnique; String indexQualifier; String indexName; Integer indexType; //Integer ordinalPosition; //String columnName; //String ascOrDesc; Integer cardinality; Integer pages; String filterCondition; Integer rowCardinality; // Intermediate holders Iterator tables; Table table; int indexCount; int[] cols; int col; int colCount; Object[] row; DITableInfo ti; HsqlProperties p; // column number mappings final int itable_cat = 0; final int itable_schem = 1; final int itable_name = 2; final int inon_unique = 3; final int iindex_qualifier = 4; final int iindex_name = 5; final int itype = 6; final int iordinal_position = 7; final int icolumn_name = 8; final int iasc_or_desc = 9; final int icardinality = 10; final int ipages = 11; final int ifilter_condition = 12; final int irow_cardinality = 13; // Initialization ti = new DITableInfo(); p = database.getProperties(); tables = p.isPropertyTrue("hsqldb.system_table_indexinfo") ? allTables() : database.schemaManager.allTablesIterator(); // Do it. while (tables.hasNext()) { table = (Table) tables.next(); if (table.isView() ||!isAccessibleTable(table)) { continue; } ti.setTable(table); tableCatalog = ns.getCatalogName(table); tableSchema = table.getSchemaName(); tableName = ti.getName(); // not supported yet filterCondition = null; // different cat for index not supported yet indexQualifier = tableCatalog; indexCount = table.getIndexCount(); // process all of the visible indices for this table for (int i = 0; i < indexCount; i++) { colCount = ti.getIndexVisibleColumns(i); if (colCount < 1) { continue; } indexName = ti.getIndexName(i); nonUnique = ti.isIndexNonUnique(i); cardinality = ti.getIndexCardinality(i); pages = ValuePool.getInt(0); rowCardinality = ti.getIndexRowCardinality(i); cols = ti.getIndexColumns(i); indexType = ti.getIndexType(i); for (int k = 0; k < colCount; k++) { col = cols[k]; row = t.getEmptyRowData(); row[itable_cat] = tableCatalog; row[itable_schem] = tableSchema; row[itable_name] = tableName; row[inon_unique] = nonUnique; row[iindex_qualifier] = indexQualifier; row[iindex_name] = indexName; row[itype] = indexType; row[iordinal_position] = ValuePool.getInt(k + 1); row[icolumn_name] = ti.getColName(col); row[iasc_or_desc] = ti.getIndexColDirection(i, col); row[icardinality] = cardinality; row[ipages] = pages; row[irow_cardinality] = rowCardinality; row[ifilter_condition] = filterCondition; t.insertSys(row); } } } t.setDataReadOnly(true); return t; } /** * Retrieves a <code>Table</code> object describing the visible * primary key columns of each accessible table defined within * this database. <p> * * Each row is a PRIMARY KEY column description with the following * columns: <p> * * <pre class="SqlCodeExample"> * TABLE_CAT VARCHAR table catalog * TABLE_SCHEM VARCHAR table schema * TABLE_NAME VARCHAR table name * COLUMN_NAME VARCHAR column name * KEY_SEQ SMALLINT sequence number within primary key * PK_NAME VARCHAR primary key constraint name * </pre> <p> * * @return a <code>Table</code> object describing the visible * primary key columns of each accessible table * defined within this database. * @throws HsqlException if an error occurs while producing the table */ final Table SYSTEM_PRIMARYKEYS() throws HsqlException { Table t = sysTables[SYSTEM_PRIMARYKEYS]; if (t == null) { t = createBlankTable(sysTableHsqlNames[SYSTEM_PRIMARYKEYS]); addColumn(t, "TABLE_CAT", Types.VARCHAR); addColumn(t, "TABLE_SCHEM", Types.VARCHAR); addColumn(t, "TABLE_NAME", Types.VARCHAR, false); // not null addColumn(t, "COLUMN_NAME", Types.VARCHAR, false); // not null addColumn(t, "KEY_SEQ", Types.SMALLINT, false); // not null addColumn(t, "PK_NAME", Types.VARCHAR); // order: COLUMN_NAME // added for unique: TABLE_NAME, TABLE_SCHEM, TABLE_CAT // false PK, as TABLE_SCHEM and/or TABLE_CAT may be null t.createPrimaryKey(null, new int[] { 3, 2, 1, 0 }, false); return t; } // calculated column values String tableCatalog; String tableSchema; String tableName; //String columnName; //Integer keySequence; String primaryKeyName; // Intermediate holders Iterator tables; Table table; Object[] row; Constraint constraint; int[] cols; int colCount; HsqlProperties p; // column number mappings final int itable_cat = 0; final int itable_schem = 1; final int itable_name = 2; final int icolumn_name = 3; final int ikey_seq = 4; final int ipk_name = 5; // Initialization p = database.getProperties(); tables = p.isPropertyTrue("hsqldb.system_table_primarykeys") ? allTables() : database.schemaManager.allTablesIterator(); while (tables.hasNext()) { table = (Table) tables.next(); if (table.isView() ||!isAccessibleTable(table) ||!table.hasPrimaryKey()) { continue; } constraint = table.getPrimaryConstraint(); tableCatalog = ns.getCatalogName(table); tableSchema = table.getSchemaName(); tableName = table.getName().name; primaryKeyName = constraint.getName().name; cols = constraint.getMainColumns(); colCount = cols.length; for (int j = 0; j < colCount; j++) { row = t.getEmptyRowData(); row[itable_cat] = tableCatalog; row[itable_schem] = tableSchema; row[itable_name] = tableName; row[icolumn_name] = table.getColumn(cols[j]).columnName.name; row[ikey_seq] = ValuePool.getInt(j + 1); row[ipk_name] = primaryKeyName; t.insertSys(row); } } t.setDataReadOnly(true); return t; } /** * Retrieves a <code>Table</code> object describing the * return, parameter and result columns of the accessible * routines defined within this database.<p> * * Each row is a procedure column description with the following * columns: <p> * * <pre class="SqlCodeExample"> * PROCEDURE_CAT VARCHAR routine catalog * PROCEDURE_SCHEM VARCHAR routine schema * PROCEDURE_NAME VARCHAR routine name * COLUMN_NAME VARCHAR column/parameter name * COLUMN_TYPE SMALLINT kind of column/parameter * DATA_TYPE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -