Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何获取oracle 11g中为特定用户创建的所有表的元数据_Java_Oracle_Oracle11g - Fatal编程技术网

Java 如何获取oracle 11g中为特定用户创建的所有表的元数据

Java 如何获取oracle 11g中为特定用户创建的所有表的元数据,java,oracle,oracle11g,Java,Oracle,Oracle11g,我在Oracle11g中有一个名为testUser的用户。现在我在用户testUser下有4个表。我只想获取用户testUser下存在的所有表的元数据。 我正在使用接口java.sql.DatabaseMetaData中提供的getTables方法。方法的签名如下所示: getTables(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String tableNamePattern, java.lang.S

我在Oracle11g中有一个名为testUser的用户。现在我在用户testUser下有4个表。我只想获取用户testUser下存在的所有表的元数据。 我正在使用接口java.sql.DatabaseMetaData中提供的getTables方法。方法的签名如下所示:

getTables(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tableNamePattern,
java.lang.String[] types);
有人能帮助我理解getTables方法的第一个和第二个参数中应该传递的值吗。 我认为在第三个参数tableNamePattern中,我必须传递“%”,在第四个参数中,我将传递只有一个元素“TABLE”的字符串数组,因为我必须获取表

我不确定第一个和第二个参数的值。如果我在第一个和第二个参数中传递null,它将尝试获取oracle中所有用户的所有表。但我想在单个用户下创建表

提前谢谢

根据oracle文档: getTables

ResultSet getTables(String catalog,
                    String schemaPattern,
                    String tableNamePattern,
                    String[] types)
                    throws SQLException

Retrieves a description of the tables available in the given catalog. Only table descriptions matching the catalog, schema, table name and type criteria are returned. They are ordered by TABLE_TYPE, TABLE_CAT, TABLE_SCHEM and TABLE_NAME.

Each table description has the following columns:

    TABLE_CAT String => table catalog (may be null)
    TABLE_SCHEM String => table schema (may be null)
    TABLE_NAME String => table name
    TABLE_TYPE String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
    REMARKS String => explanatory comment on the table
    TYPE_CAT String => the types catalog (may be null)
    TYPE_SCHEM String => the types schema (may be null)
    TYPE_NAME String => type name (may be null)
    SELF_REFERENCING_COL_NAME String => name of the designated "identifier" column of a typed table (may be null)
    REF_GENERATION String => specifies how values in SELF_REFERENCING_COL_NAME are created. Values are "SYSTEM", "USER", "DERIVED". (may be null) 

Note: Some databases may not return information for all tables.

Parameters:
    catalog - a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search
    schemaPattern - a schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search
    tableNamePattern - a table name pattern; must match the table name as it is stored in the database
    types - a list of table types, which must be from the list of table types returned from getTableTypes(),to include; null returns all types 
Returns:
    ResultSet - each row is a table description 
缩短

  • 第一个参数
    catalog
    只不过是服务器实例
  • 第二个参数
    schema
    只是数据库中的名称空间,与用户帐户相同

  • 第一个参数可以传递null,第二个参数可以传递username(TESTUSER-大写很重要)。目录对于Oracle数据库来说并不重要,schemaPattern(名称)和用户名在Oracle数据库中是相同的