I need information about table and column name from the name of the constraint.
exists someone similar to connection.getMetadata().getX to retrieve the constraint information?
my test case is in Oracle Database, but my best solution I just want to solve with jdbc
If you are talking about foreign key and primary key constraints. The DatabaseMetaData
does provide methods for retrieving this information: you can use getImportedKeys(..)
and getCrossReference(..)
for foreign keys, and getPrimaryKeys(..)
and getExportedKeys(..)
for primary keys.
Just be careful how you use them: getCrossReference(..)
and getExportedKeys
are a bit counter-intuitive in my opinion.
If you also need unique constraints, then you should be able to use getIndexInfo(..)
with passing true
for the parameter unique
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With