我正在尝试从我的应用程序中读取Oracle表信息。要获取表描述,我在我的应用程序上执行此查询:
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
String sql = "SELECT DBMS_METADATA.GET_DDL('TABLE', 'CONTRACT_TABLE' ,'SCHEMA_NAME') FROM DUAL";
preparedStatement = connection.prepareStatement(sql);
resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
Clob clob = resultSet.getClob(1);
String str = clob.getSubString(1, (int)clob.length());
return str;
} else {
throw new DBPlatformException("Object not available [Schema: "
+ schema + "].[Name: " + objectName + "]!");
}
以下是执行查询的代码块:
CREATE TABLE "SCHEMA_NAME"."CONTRACT_TABLE"
( "CONTRACT_ID" NUMBER,
"START_DATE" DATE,
"END_DATE" DATE
) PCTFREE 0 PCTUSED 0 INITRANS 1 MAXTRANS 255
COMPRESS FOR QUERY HIGH NOLOGGING
STORAGE(
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TMP_SPACE"
PARTITION BY HASH ("CONTRACT_ID")
(PARTITION "P01" SEGMENT CREATION DEFERRED
TABLESPACE "TMP_SPACE"
COMPRESS FOR QUERY HIGH ,
PARTITION "P02" SEGMENT CREATION DEFERRED
TABLESPACE "TMP_SPACE"
COMPRESS FOR QUERY HIGH ,
PARTITION "P03" SEGMENT CREATION DEFERRED
TABLESPACE "TMP_SPACE"
COMPRESS FOR QUERY HIGH ,
PARTITION "P04" SEGMENT CREATION DEFERRED
TABLESPACE "TMP_SPACE"
COMPRESS FOR QUERY HIGH ,
PARTITION "P05" SEGMENT CREATION DEFERRED
TABLESPACE "TMP_SPACE"
COMPRESS FOR QUERY HIGH )
PARALLEL 32
当我直接在数据库上运行sql时,我得到了这个结果:
CREATE TABLE "SCHEMA_NAME"."CONTRACT_TABLE"
( "CONTRACT_ID" NUMBER,
"START_DATE" DATE,
"END_DATE" DATE
)
PARTITION BY HASH ("CONTRACT_ID")
(PARTITION "P01" ,
PARTITION "P02" ,
PARTITION "P03" ,
PARTITION "P04" ,
PARTITION "P05" )
当我运行我的应用程序时,它会返回如下结果:
public static IEqualityComparer GetEqualityComparer(this NameObjectCollectionBase nameObjectCollection)
{
PropertyInfo propertyInfo = typeof(NameObjectCollectionBase).GetProperty("Comparer", BindingFlags.Instance | BindingFlags.NonPublic);
return (IEqualityComparer)propertyInfo.GetValue(nameObjectCollection);
}
public static IEqualityComparer<string> GetEqualityComparer(this NameValueCollection nameValueCollection)
{
return (IEqualityComparer<string>)((NameObjectCollectionBase)nameValueCollection).GetEqualityComparer();
}
public static Dictionary<string, string> ToDictionary(this NameValueCollection nameValueCollection)
{
Dictionary<string, string> dictionary =
nameValueCollection.AllKeys.ToDictionary(x => x, x => nameValueCollection[x], nameValueCollection.GetEqualityComparer());
return dictionary;
}
我的应用程序返回的结果信息较少。我需要知道表是否并行,但我的应用程序无法向我提供该信息。
我试图找出查询结果不同的原因以及如何检索并行信息。
答案 0 :(得分:1)
尝试执行
begin
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',TRUE);
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'TABLESPACE',TRUE);
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SEGMENT_ATTRIBUTES',TRUE);
end;
/
在java中声明并查看结果是否发生变化之前。