I have a string containing an SQL statement. I want to know if the query will change the data or the structure of the database, or if it will read only the data. Is there any way to do this?
Additional information: in our application, we must allow users to enter SQL queries, mainly as part of the application reporting system. These SQL queries should be allowed to read everything they like from the database, but they are not allowed to change anything. No updates, removes insert, table drops, constraint removal, etc.
At the moment, I am only checking if the first word in the string is "select", but it is too compressive and too uncertain.
source share