I do not know the high level API for comparing schemas. I used DatabaseMetaData so that it is not difficult to find the differences ig for retrieving all the tables can be done something like this:
DatabaseMetaData meta = con.getMetaData(); ResultSet res = meta.getTables(null, null, null, new String[] {"TABLE"}); System.out.println("List of tables: "); while (res.next()) { System.out.println( " "+res.getString("TABLE_CAT") + ", "+res.getString("TABLE_SCHEM") + ", "+res.getString("TABLE_NAME") + ", "+res.getString("TABLE_TYPE") + ", "+res.getString("REMARKS")); } res.close();
The following methods are also important to your intent:
getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) getExportedKeys(String catalog, String schema, String table) getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) getPrimaryKeys(String catalog, String schema, String table)
source share