db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <knut.hat...@oracle.com>
Subject Re: List columns that make up an index
Date Mon, 23 Jan 2012 08:21:32 GMT
Bryan Pendleton <bpendleton.derby@gmail.com> writes:

>> What root canal.... Just to get column names of an index....
> I always just use ij's "show indexes" command.
> http://db.apache.org/derby/docs/10.8/tools/rtoolsijcomrefshow.html

Alternatively, from a Java application, this information can be
retrieved by a calling DatabaseMetaData.getIndexInfo().

Something along these lines would print all the indexed columns in the
table T1 in schema S, and the name of the indexes:

    ResultSet rs = conn.getMetaData().getIndexInfo(null, "S", "T1", false, false);
    while (rs.next()) {
        System.out.println(rs.getString("INDEX_NAME") + ": " + rs.getString("COLUMN_NAME"));

Hope this helps,

Knut Anders

View raw message