JDBC Metada Retrieves Constraint Information

I need information about the name of the table and column on behalf of the constraint.

there is someone similar to connection.getMetadata (). getX for restriction information?

my test case is in an Oracle database, but my best solution I just want to solve with jdbc

+5
source share
2 answers

If you are talking about foreign keys and primary key constraints. DatabaseMetaDataIt provides methods to retrieve this information: you can use getImportedKeys(..)and getCrossReference(..)for external keys and getPrimaryKeys(..)and getExportedKeys(..)for primary keys.

Just be careful how you use them: getCrossReference(..)and getExportedKeys, in my opinion, a little intuitive.

, getIndexInfo(..) true unique.

+7

USER_CONSTRAINTS ALL_CONSTRAINTS.
where where.

:

select 
    CONSTRAINT_NAME,
    CONSTRAINT_TYPE,
    TABLE_NAME,
    ...
from
    USER_CONSTRAINTS
where
    CONSTRAINT_NAME like concat(?, '%');
+3

All Articles