JDBC 'getIndexInfo()' method return data lacks 'is Primary Index' flag?
I need to get the following information of all table indices of a table with the JDBC 'getIndexInfo()' method to be able to create a similar table but with modified indices.
- The index number - The index column name of the index number - The index column position of the index number - The unique index flag of the index number - Primary or Secondary index flag of the index number
The first 4 are returned nicely by the 'getIndexInfo()' method.
But I'cant see any information returned by the 'getIndexInfo()' method that looks like a 'Primary or Secondary Index' flag.
My current workarounds are: - It looks like that the Primary Index is always the first index returned by the 'getIndexInfo()' method. - Requesting the index information from table 'DBC.Indices'. (SELECT indexNumber, indexType FROM DBC.Indices)
Does anybody know how to get something like an 'index is the primary index' flag with any JDBC method, except requesting 'DBC.Indices' with a SELECT?
DatabaseMetaData.getIndexInfo is a vendor-neutral API, so the Teradata JDBC Driver is limited in terms of the information that we can provide.
A "primary index" is a Teradata-specific concept, and there's not a clear way for the Teradata JDBC Driver to provide that information via the DatabaseMetaData.getIndexInfo method.
It sounds like your application is Teradata-specific, since you mentioned that your application must be aware of a table's primary index. You should certainly consider querying DBC.Indices (or DBC.IndicesV on recent Teradata Database releases) directly to obtain the information you need.
Please note that the Teradata JDBC Driver simply queries DBC.Indices or DBC.IndicesV to obtain the information returned from the DatabaseMetaData.getIndexInfo method.