I need to know a way to check from a Java Desktop App, if a Oracle's view exist in the current DB before execute a query otherwise I will get a lot of troubles...
thanks in advance
You can always query the Oracle data dictionary. Something like
SELECT COUNT(*)
FROM all_views
WHERE view_name = <<the name of the view>>
AND owner = <<the owner of the view>>
will tell you whether you have access to a view owned by the specified user with the specified name.
Alternately, you can use a more Java-centric approach. You can create a DatabaseMetaData
object from your Connection
and call getTables
to get a list of all the tables and views that you have access to. You can pass getTables
a specific table or view name (or a pattern) to restrict the results.
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