Search code examples
javaoracle-databasejdbctriggersdatabase-metadata

How to get all trigger names from a database using Java JDBC?


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);

Solution

  • 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")
    }