-
- All Superinterfaces:
Scope
public interface Meta extends Scope
A wrapping object forDatabaseMetaData
or for other sources of database meta information (e.g.InformationSchema
)This object can be obtained through
DSLContext.meta()
in order to provide convenient access to your database meta data. This abstraction has two purposes:- To increase API convenience, as no checked
SQLException
is thrown, only the uncheckedDataAccessException
- To increase API convenience, as the returned objects are always jOOQ
objects, not JDBC
ResultSet
objects with hard-to-remember API constraints
- Author:
- Lukas Eder
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Meta
apply(String migration)
Apply a migration to this meta to produce a newMeta
.Meta
apply(Collection<? extends Query> migration)
Apply a migration to this meta to produce a newMeta
.Meta
apply(Queries migration)
Apply a migration to this meta to produce a newMeta
.Meta
apply(Query... migration)
Apply a migration to this meta to produce a newMeta
.Queries
ddl()
Generate a creation script for the entire meta data.Queries
ddl(DDLExportConfiguration configuration)
Generate a creation script for the entire meta data.Catalog
getCatalog(String name)
Get a catalog object by name from the underlying meta data source, ornull
if no such object exists.Catalog
getCatalog(Name name)
Get a catalog object by name from the underlying meta data source, ornull
if no such object exists.List<Catalog>
getCatalogs()
Get all catalog objects from the underlying meta data source.List<Index>
getIndexes()
Get all indexes from the underlying meta data sources.List<UniqueKey<?>>
getPrimaryKeys()
Get all primary keys from the underlying meta data source.List<Schema>
getSchemas()
Get all schema objects from the underlying meta data source.List<Schema>
getSchemas(String name)
Get all schema objects by name from the underlying meta data source.List<Schema>
getSchemas(Name name)
Get all schema objects by name from the underlying meta data source.List<Sequence<?>>
getSequences()
Get all sequence objects from the underlying meta data source.List<Sequence<?>>
getSequences(String name)
Get all sequence objects by name from the underlying meta data source.List<Sequence<?>>
getSequences(Name name)
Get all sequence objects by name from the underlying meta data source.List<Table<?>>
getTables()
Get all table objects from the underlying meta data source.List<Table<?>>
getTables(String name)
Get all table objects by name from the underlying meta data source.List<Table<?>>
getTables(Name name)
Get all table objects by name from the underlying meta data source.InformationSchema
informationSchema()
Export to theInformationSchema
format.Queries
migrateTo(Meta other)
Generate a migration script to get from this meta data to another one.Queries
migrateTo(Meta other, MigrationConfiguration configuration)
Generate a migration script to get from this meta data to another one.
-
-
-
Method Detail
-
getCatalogs
@Support List<Catalog> getCatalogs() throws DataAccessException
Get all catalog objects from the underlying meta data source.For those databases that don't really support JDBC meta data catalogs, a single empty catalog (named
""
) will be returned. In other words, there is always at least one catalog in a database.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getCatalog
@Support Catalog getCatalog(String name) throws DataAccessException
Get a catalog object by name from the underlying meta data source, ornull
if no such object exists.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getCatalog
@Support Catalog getCatalog(Name name) throws DataAccessException
Get a catalog object by name from the underlying meta data source, ornull
if no such object exists.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getSchemas
@Support List<Schema> getSchemas() throws DataAccessException
Get all schema objects from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getSchemas
@Support List<Schema> getSchemas(String name) throws DataAccessException
Get all schema objects by name from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getSchemas
@Support List<Schema> getSchemas(Name name) throws DataAccessException
Get all schema objects by name from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getTables
@Support List<Table<?>> getTables() throws DataAccessException
Get all table objects from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getTables
@Support List<Table<?>> getTables(String name) throws DataAccessException
Get all table objects by name from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getTables
@Support List<Table<?>> getTables(Name name) throws DataAccessException
Get all table objects by name from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getSequences
@Support({AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,INGRES,ORACLE,POSTGRES,SQLSERVER2012,SYBASE}) List<Sequence<?>> getSequences() throws DataAccessException
Get all sequence objects from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getSequences
@Support({AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,INGRES,ORACLE,POSTGRES,SQLSERVER2012,SYBASE}) List<Sequence<?>> getSequences(String name) throws DataAccessException
Get all sequence objects by name from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getSequences
@Support({AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,INGRES,ORACLE,POSTGRES,SQLSERVER2012,SYBASE}) List<Sequence<?>> getSequences(Name name) throws DataAccessException
Get all sequence objects by name from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getPrimaryKeys
@Support List<UniqueKey<?>> getPrimaryKeys() throws DataAccessException
Get all primary keys from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getIndexes
@Support List<Index> getIndexes() throws DataAccessException
Get all indexes from the underlying meta data sources.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
ddl
Queries ddl() throws DataAccessException
Generate a creation script for the entire meta data.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
ddl
Queries ddl(DDLExportConfiguration configuration) throws DataAccessException
Generate a creation script for the entire meta data.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
apply
Meta apply(String migration) throws DataAccessException
Apply a migration to this meta to produce a newMeta
.- Throws:
DataAccessException
- If something went wrong fetching the meta objects- See Also:
Parser.parse(String)
-
apply
Meta apply(Query... migration) throws DataAccessException
Apply a migration to this meta to produce a newMeta
.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
apply
Meta apply(Collection<? extends Query> migration) throws DataAccessException
Apply a migration to this meta to produce a newMeta
.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
apply
Meta apply(Queries migration) throws DataAccessException
Apply a migration to this meta to produce a newMeta
.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
migrateTo
Queries migrateTo(Meta other) throws DataAccessException
Generate a migration script to get from this meta data to another one.See
migrateTo(Meta, MigrationConfiguration)
for more details.- Throws:
DataAccessException
- If something went wrong fetching the meta objects- See Also:
migrateTo(Meta, MigrationConfiguration)
-
migrateTo
Queries migrateTo(Meta other, MigrationConfiguration configuration) throws DataAccessException
Generate a migration script to get from this meta data to another one.To some extent, some database migrations can be generated automatically by comparing two versions of a schema. This is what
migrateTo()
does. It supports:- Schema additions / removals
- Table additions / removals
- Column additions / removals
- Column data type changes
- Constraint additions / removals
- Index additions / removals
- Sequence additions / removals
- Comment additions / removals
More complex, structural changes, such as moving some columns from one table to another, or turning a to-one relationship into a to-many relationship, as well as data migrations, can currently not be detected automatically.
- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
informationSchema
InformationSchema informationSchema() throws DataAccessException
Export to theInformationSchema
format.This allows for serialising schema meta information as XML using JAXB. See also
Constants.XSD_META
for details.- Throws:
DataAccessException
-
-