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

📄 jdbcdatabasemetadata.java

📁 一个可以在applet窗体上持行sql语句并显示返回结果的程序
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
   *	<LI><B>TABLE_NAME</B> String => table name
   *	<LI><B>COLUMN_NAME</B> String => column name
   *	<LI><B>GRANTOR</B> => grantor of access (may be null)
   *	<LI><B>GRANTEE</B> String => grantee of access
   *	<LI><B>PRIVILEGE</B> String => name of access (SELECT,
   *      INSERT, UPDATE, REFRENCES, ...)
   *	<LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
   *      to grant to others; "NO" if not; null if unknown
   *  </OL>
   *
   * @param catalog a catalog name; "" retrieves those without a
   * catalog; null means drop catalog name from the selection criteria
   * @param schema a schema name; "" retrieves those without a schema
   * @param table a table name
   * @param columnNamePattern a column name pattern
   * @return ResultSet - each row is a column privilege description
   * @exception SQLException if a database access error occurs
   * @see #getSearchStringEscape
   */
  public ResultSet getColumnPrivileges(String catalog,String schema,
  String tableP,String columnNamePattern) throws SQLException {
    String table="SYSTEM_COLUMNPRIVILEGES";
    String where=null;
    if(tableP!=null) {
      // other databases may not support table as pattern
      where="TABLE_NAME LIKE '"+tableP+"'";
    }
    if(columnNamePattern!=null) {
      where=addWhere(where,"COLUMN_NAME LIKE '"+columnNamePattern+"'");
    }
    return executeSelect(table,where);
  }
  /**
   * Gets a description of the access rights for each table available
   * in a catalog. Note that a table privilege applies to one or
   * more columns in the table. It would be wrong to assume that
   * this priviledge applies to all columns (this may be true for
   * some systems but is not true for all.)
   *
   * <P>Only privileges matching the schema and table name
   * criteria are returned.  They are ordered by TABLE_SCHEM,
   * TABLE_NAME, and PRIVILEGE.
   *
   * <P>Each privilige description has the following columns:
   *  <OL>
   *	<LI><B>TABLE_CAT</B> String => table catalog (may be null)
   *	<LI><B>TABLE_SCHEM</B> String => table schema (may be null)
   *	<LI><B>TABLE_NAME</B> String => table name
   *	<LI><B>GRANTOR</B> => grantor of access (may be null)
   *	<LI><B>GRANTEE</B> String => grantee of access
   *	<LI><B>PRIVILEGE</B> String => name of access (SELECT,
   *      INSERT, UPDATE, REFRENCES, ...)
   *	<LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted 
   *      to grant to others; "NO" if not; null if unknown
   *  </OL>
   *
   * @param catalog a catalog name; "" retrieves those without a
   * catalog; null means drop catalog name from the selection criteria
   * @param schemaPattern a schema name pattern; "" retrieves those
   * without a schema
   * @param tableNamePattern a table name pattern 
   * @return ResultSet - each row is a table privilege description
   * @exception SQLException if a database access error occurs
   * @see #getSearchStringEscape
   */
  public ResultSet getTablePrivileges(String catalog,String schemaPattern,
  String tableNamePattern) throws SQLException {
    String table="SYSTEM_TABLEPRIVILEGES";
    String where=null;
    if(tableNamePattern!=null) {
      where="TABLE_NAME LIKE '"+tableNamePattern+"'";
    }
    return executeSelect(table,where);
  }
  /**
   * Gets a description of a table's optimal set of columns that
   * uniquely identifies a row. They are ordered by SCOPE.
   *
   * <P>Each column description has the following columns:
   *  <OL>
   *	<LI><B>SCOPE</B> short => actual scope of result
   *      <UL>
   *      <LI> bestRowTemporary - very temporary, while using row
   *      <LI> bestRowTransaction - valid for remainder of current transaction
   *      <LI> bestRowSession - valid for remainder of current session
   *      </UL>
   *	<LI><B>COLUMN_NAME</B> String => column name
   *	<LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
   *	<LI><B>TYPE_NAME</B> String => Data source dependent type name,
   *  for a UDT the type name is fully qualified
   *	<LI><B>COLUMN_SIZE</B> int => precision
   *	<LI><B>BUFFER_LENGTH</B> int => not used
   *	<LI><B>DECIMAL_DIGITS</B> short	 => scale
   *	<LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column 
   *      like an Oracle ROWID
   *      <UL>
   *      <LI> bestRowUnknown - may or may not be pseudo column
   *      <LI> bestRowNotPseudo - is NOT a pseudo column
   *      <LI> bestRowPseudo - is a pseudo column
   *      </UL>
   *  </OL>
   *
   * @param catalog a catalog name; "" retrieves those without a
   * catalog; null means drop catalog name from the selection criteria
   * @param schema a schema name; "" retrieves those without a schema
   * @param table a table name
   * @param scope the scope of interest; use same values as SCOPE
   * @param nullable include columns that are nullable?
   * @return ResultSet - each row is a column description
   * @exception SQLException if a database access error occurs
   */
  public ResultSet getBestRowIdentifier(String catalog,String schema,
  String table,int scope,boolean nullable) throws SQLException {
    return executeSelect("SYSTEM_BESTROWIDENTIFIER",null);
  }
  /**
   * Gets a description of a table's columns that are automatically
   * updated when any value in a row is updated.  They are
   * unordered.
   *
   * <P>Each column description has the following columns:
   *  <OL>
   *	<LI><B>SCOPE</B> short => is not used
   *	<LI><B>COLUMN_NAME</B> String => column name
   *	<LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
   *	<LI><B>TYPE_NAME</B> String => Data source dependent type name
   *	<LI><B>COLUMN_SIZE</B> int => precision
   *	<LI><B>BUFFER_LENGTH</B> int => length of column value in bytes
   *	<LI><B>DECIMAL_DIGITS</B> short	 => scale
   *	<LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column
   *      like an Oracle ROWID
   *      <UL>
   *      <LI> versionColumnUnknown - may or may not be pseudo column
   *      <LI> versionColumnNotPseudo - is NOT a pseudo column
   *      <LI> versionColumnPseudo - is a pseudo column
   *      </UL>
   *  </OL>
   *
   * @param catalog a catalog name; "" retrieves those without a
   * catalog; null means drop catalog name from the selection criteria
   * @param schema a schema name; "" retrieves those without a schema
   * @param table a table name
   * @return ResultSet - each row is a column description
   * @exception SQLException if a database access error occurs
   */
  public ResultSet getVersionColumns(String catalog,String schema,
  String table) throws SQLException {
    return executeSelect("SYSTEM_VERSIONCOLUMNS",null);
  }
  /**
   * Gets a description of a table's primary key columns.  They
   * are ordered by COLUMN_NAME.
   *
   * <P>Each primary key column description has the following columns:
   *  <OL>
   *	<LI><B>TABLE_CAT</B> String => table catalog (may be null)
   *	<LI><B>TABLE_SCHEM</B> String => table schema (may be null)
   *	<LI><B>TABLE_NAME</B> String => table name
   *	<LI><B>COLUMN_NAME</B> String => column name
   *	<LI><B>KEY_SEQ</B> short => sequence number within primary key
   *	<LI><B>PK_NAME</B> String => primary key name (may be null)
   *  </OL>
   *
   * @param catalog a catalog name; "" retrieves those without a
   * catalog; null means drop catalog name from the selection criteria
   * @param schema a schema name; "" retrieves those
   * without a schema
   * @param table a table name
   * @return ResultSet - each row is a primary key column description
   * @exception SQLException if a database access error occurs
   */
  public ResultSet getPrimaryKeys(String catalog,String schema,
  String tableP) throws SQLException {
    String table="SYSTEM_PRIMARYKEYS";
    String where=null;
    if(tableP!=null) {
      // other databases may not support table as pattern
      where="TABLE_NAME LIKE '"+tableP+"'";
    }
    return executeSelect(table,where);
  }
  /**
   * Gets a description of the primary key columns that are
   * referenced by a table's foreign key columns (the primary keys
   * imported by a table).  They are ordered by PKTABLE_CAT,
   * PKTABLE_SCHEM, PKTABLE_NAME, and KEY_SEQ.
   *
   * <P>Each primary key column description has the following columns:
   *  <OL>
   *	<LI><B>PKTABLE_CAT</B> String => primary key table catalog 
   *      being imported (may be null)
   *	<LI><B>PKTABLE_SCHEM</B> String => primary key table schema
   *      being imported (may be null)
   *	<LI><B>PKTABLE_NAME</B> String => primary key table name
   *      being imported
   *	<LI><B>PKCOLUMN_NAME</B> String => primary key column name
   *      being imported
   *	<LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
   *	<LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
   *	<LI><B>FKTABLE_NAME</B> String => foreign key table name
   *	<LI><B>FKCOLUMN_NAME</B> String => foreign key column name
   *	<LI><B>KEY_SEQ</B> short => sequence number within foreign key
   *	<LI><B>UPDATE_RULE</B> short => What happens to 
   *       foreign key when primary is updated:
   *      <UL>
   *      <LI> importedNoAction - do not allow update of primary 
   *               key if it has been imported
   *      <LI> importedKeyCascade - change imported key to agree 
   *               with primary key update
   *      <LI> importedKeySetNull - change imported key to NULL if 
   *               its primary key has been updated
   *      <LI> importedKeySetDefault - change imported key to default values 
   *               if its primary key has been updated
   *      <LI> importedKeyRestrict - same as importedKeyNoAction 
   *                                 (for ODBC 2.x compatibility)
   *      </UL>
   *	<LI><B>DELETE_RULE</B> short => What happens to 
   *      the foreign key when primary is deleted.
   *      <UL>
   *      <LI> importedKeyNoAction - do not allow delete of primary 
   *               key if it has been imported
   *      <LI> importedKeyCascade - delete rows that import a deleted key
   *      <LI> importedKeySetNull - change imported key to NULL if 
   *               its primary key has been deleted
   *      <LI> importedKeyRestrict - same as importedKeyNoAction
   *                                 (for ODBC 2.x compatibility)
   *      <LI> importedKeySetDefault - change imported key to default if
   *               its primary key has been deleted
   *      </UL>
   *	<LI><B>FK_NAME</B> String => foreign key name (may be null)
   *	<LI><B>PK_NAME</B> String => primary key name (may be null)
   *	<LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key 
   *      constraints be deferred until commit
   *      <UL>
   *      <LI> importedKeyInitiallyDeferred - see SQL92 for definition
   *      <LI> importedKeyInitiallyImmediate - see SQL92 for definition 
   *      <LI> importedKeyNotDeferrable - see SQL92 for definition 
   *      </UL>
   *  </OL>
   *
   * @param catalog a catalog name; "" retrieves those without a
   * catalog; null means drop catalog name from the selection criteria
   * @param schema a schema name; "" retrieves those
   * without a schema
   * @param table a table name
   * @return ResultSet - each row is a primary key column description
   * @exception SQLException if a database access error occurs
   * @see #getExportedKeys
   */
  public ResultSet getImportedKeys(String catalog,String schema,
  String table) throws SQLException {
    return executeSelect("SYSTEM_IMPORTEDKEYS",null);
  }
  /**
   * Gets a description of the foreign key columns that reference a
   * table's primary key columns (the foreign keys exported by a
   * table).  They are ordered by FKTABLE_CAT, FKTABLE_SCHEM,
   * FKTABLE_NAME, and KEY_SEQ.
   *
   * <P>Each foreign key column description has the following columns:
   *  <OL>
   *	<LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
   *	<LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
   *	<LI><B>PKTABLE_NAME</B> String => primary key table name
   *	<LI><B>PKCOLUMN_NAME</B> String => primary key column name
   *	<LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
   *      being exported (may be null)
   *	<LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
   *      being exported (may be null)
   *	<LI><B>FKTABLE_NAME</B> String => foreign key table name
   *      being exported
   *	<LI><B>FKCOLUMN_NAME</B> String => foreign key column name
   *      being exported
   *	<LI><B>KEY_SEQ</B> short => sequence number within foreign key
   *	<LI><B>UPDATE_RULE</B> short => What happens to
   *       foreign key when primary is updated:
   *      <UL>
   *      <LI> importedNoAction - do not allow update of primary 
   *               key if it has been imported
   *      <LI> importedKeyCascade - change imported key to agree 
   *               with primary key update
   *      <LI> importedKeySetNull - change imported key to NULL if 
   *               its primary key has been updated
   *      <LI> importedKeySetDefault - change imported key to default values 
   *               if its primary key has been updated
   *      <LI> importedKeyRestrict - same as importedKeyNoAction 
   *                                 (for ODBC 2.x compatibility)
   *      </UL>
   *	<LI><B>DELETE_RULE</B> short => What happens to 
   *      the foreign key when primary is deleted.
   *      <UL>
   *      <LI> importedKeyNoAction - do not allow delete of primary 
   *               key if it has been imported
   *      <LI> importedKeyCascade - delete rows that import a deleted key
   *      <LI> importedKeySetNull - change imported key to NULL if 
   *               its primary key has been deleted
   *      <LI> importedKeyRestrict - same as importedKeyNoAction 
   *                                 (for ODBC 2.x compatibility)
   *      <LI> importedKeySetDefault - change imported key to default if 
   *               its primary key has been deleted
   *      </UL>
   *	<LI><B>FK_NAME</B> String => foreign key name (may be null)
   *	<LI><B>PK_NAME</B> String => primary key name (may be null)
   *	<LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key 
   *      constraints be deferred until commit
   *      <UL>
   *      <LI> importedKeyInitiallyDeferred - see SQL92 for definition
   *      <LI> importedKeyInitiallyImmediate - see SQL92 for definition 
   *      <LI> importedKeyNotDeferrable - see SQL92 for definition 
   *      </UL>
   *  </OL>
   *
   * @param catalog a catalog name; "" retrieves those without a
   * catalog; null means drop catalog name from the selection criteria
   * @param schema a schema name; "" retrieves those
   * without a schema
   * @param table a table name
   * @return ResultSet - each row is a foreign key column description
   * @exception SQLException if a database access error occurs
   * @see #getImportedKeys
   */
  public ResultSet getExportedKeys(String catalog,String schema,
  String table) throws SQLException {
    return executeSelect("SYSTEM_EXPORTEDKEYS",null);
  }
  /**
   * Gets a description of the foreign key columns in the foreign key
   * table that reference the primary key columns of the primary key
   * table (describe how one table imports another's key.) This
   * should normally return a single foreign key/primary key pair
   * (most tables only import a foreign key from a table once.)  They
   * are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and
   * KEY_SEQ.
   *
   * <P>Each foreign key column description has the following columns:
   *  <OL>
   *	<LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
   *	<LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
   *	<LI><B>PKTABLE_NAME</B> String => primary key table name
   *	<LI><B>PKCOLUMN_NAME</B> String => primary key column name
   *	<LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
   *      being exported (may be null)
   *	<LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
   *      being exported (may be null)
   *	<LI><B>FKTABLE_NAME</B> String => foreign key table name
   *      being exported
   *	<LI><B>FKCOLUMN_NAME</B> String => foreign key column name
   *      being exported
   *	<LI><B>KEY_SEQ</B> short => sequence number within foreign key
   *	<LI><B>UPDATE_RULE</B> short => What happens to 
   *       foreign key when primary is updated:
   *      <UL>
   *      <LI> importedNoAction - do not allow update of primary 
   *               key if it has been imported
   *      <LI> importedKeyCascade - change imported key to agree
   *               with primary key update
   *      <LI> importedKeySetNull - change imported key to NULL if
   *               its primary key has been updated
   *      <LI> importedKeySetDefault - change imported key to default values 
   *               if its primary key has been updated
   *      <LI> importedKeyRestrict - same as importedKeyNoAction
   *                                 (for ODBC 2.x compatibility)
   *      </UL>
   *	<LI><B>DELETE_RULE</B> short => What happens to
   *      the foreign key when primary is deleted.
   *      <UL>
   *      <LI> importedKeyNoAction - do not allow delete of primary 
   *               key if it has been imported
   *      <LI> importedKeyCascade - delete rows that import a deleted key
   *      <LI> importedKeySetNull

⌨️ 快捷键说明

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