Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Oracle: how can I tell if an SQL query will cause changes without executing it?

I've got a string containing an SQL statement. I want to find out whether the query will modify data or database structure, or if it will only read data. Is there some way to do this?

More info: In our application we need to let the users enter SQL-queries, mainly as part of the applications report system. These SQL queries should be allowed to read whatever they like from the databse, but they shouldn't be allowed to modify anything. No updates, deletes insert, table drops, constraint removals etc.

As of now I only test whether the first word in the string is "select", but this is too constricting and too insecure.

like image 339
Svein Bringsli Avatar asked Nov 28 '22 23:11

Svein Bringsli


1 Answers

You should grant only select privileges on your tables for the login used by the application to be sure.

like image 69
softveda Avatar answered Dec 10 '22 04:12

softveda