问题
I'd like to retrieve all trigger names from an Oracle database schema.
I use getFunctions to retrieve all functions but i can't find another one for the triggers.
DatabaseMetaData dbmd;
ResultSet result = dbmd.getFunctions(null, Ousername, null);
回答1:
You can do it using metadata.
DatabaseMetaData dbmd = dbConnection.getMetaData();
ResultSet result = dbmd.getTables("%", Ousername, "%", new String[]{ "TRIGGER" });
while (result.next()) {
result.getString("TABLE_NAME")
}
回答2:
The JDBC API does not provide a standard way to retrieve trigger information from the DatabaseMetaData. In fact, the word "trigger" does not even appear in the Javadoc. The accepted answer may work for Oracle, but it is not documented, and it certainly does not work for other databases like HSQL and PostgreSQL.
The only way, at this time, to retrieve trigger information without finding some undocumented backdoor hack in the JDBC driver is to issue database specific queries.
来源:https://stackoverflow.com/questions/30074300/how-to-get-all-trigger-names-from-a-database-using-java-jdbc