Does anybody are conscious of a Java library that delivers a helpful abstraction for examining and adjusting arbitrary relational database schemata? I am considering something which could do such things as

LibraryClass dbLib = ...;
DbSchema schema = dbLib.getSchema("my_schema");
List<DbTable> tables = schema.getTables();


DbTable myTable  = ...
for(DbColumn col : myTable.getColumns()){
    ... = col.getType();

as well as manipulate tables like

    new DbColumn("my_new_column", Type.UNSIGNED_INTEGER);

DbColumn myColumn = ...

Most Database modeling tools may have this kind of abstraction internally, but can there be one out of Java will be able to use, or will I must roll my very own?

JDBC itself has this kind of abstraction. Take a look at java.sql.DatabaseMetaData. However, it is really an optional area of the standard also it is dependent around the JDBC driver you're using wether it's implemented or otherwise.

DdlUtils has what you are searching for. ReadOrcreate schemas to/from XML (in Torque format) or perhaps a live database, as well as define the database schema in pure Java. Even better, browse the on-line doco, the correct answer is good.

I've not tried on the extender in a long time but Hibernate once had tools for manipulating data models at build time. Hibernate also offers the idea dialects which may be useful if you are focusing on several database vendor.

After I was at MetaMatrix, we built this type of factor using EMF (Eclipse Modeling Framework) where we produced a representational meta-model in UML, then produced it from code. The excellent factor about metamodeling is when you're doing so well, you are able to interoperate things across metamodels, provided you earn good options from the meta-meta-model.

We had an importer that will import metadata in the JDBC API and make the right equivalent model objects (database, table, column, secrets, etc).

This code may be free at some point given that they got bought by JBoss however i don't believe it is yet.