Deepak Beehyv wrote:
> Hi all,
> We are trying to use the getColumns() and getTables() functions from
> DatabaseMetaData, but we are getting indexes as well in getTables() and
> indexColumns from getColumns() call. We are able to filter out indexes from
> getTables using tableType column available but were unable to do that for
> columns as tableType is not captured.
> I would like to know if getting indexes in getTables() and indexColumns in
> getColumns is warranted or a bug. If such a behaviour is warranted, is there any
> alternate solution.
>
> --
> regards
> N.Deepak Ram
>
>
Hello N.Deepak,
1. DatabaseMetaData.getTables()
Each databases seems to decide what table types are available for
this function call.
PostgreSQL
Table Types: FOREIGN TABLE
Table Types: INDEX
Table Types: MATERIALIZED VIEW
Table Types: SEQUENCE
Table Types: SYSTEM INDEX
Table Types: SYSTEM TABLE
Table Types: SYSTEM TOAST INDEX
Table Types: SYSTEM TOAST TABLE
Table Types: SYSTEM VIEW
Table Types: TABLE
Table Types: TEMPORARY INDEX
Table Types: TEMPORARY SEQUENCE
Table Types: TEMPORARY TABLE
Table Types: TEMPORARY VIEW
Table Types: TYPE
Table Types: VIEW
While, MariaDB
Table Types: BASE TABLE
Table Types: SYSTEM VIEW
Table Types: VIEW
If the database decides at its core to have index tables then
they are going to be returned unless filtered via getTables().
So this would seem warranted and not a bug.
2. DatabaseMetaData.getColumns()
According to the Java API:
Retrieves a description of table columns available in the specified catalog.
So it retrieves all columns in a db specified for every table unfiltered
by the arguments. If the table has indexes they will be retrieved.
So again this would seem correct and not a bug.
Perhaps a more specific description of what you are trying to accomplish
could help to more fully answer the question of an alternative solution?
danap