Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine if a SQL query alters the database structure

I'm trying to find out if a string contains certain SQL commands that alter the database by:

  • creating new tables
  • deleting existing tables
  • creating new table columns
  • deleting existing table columns

Right now I'm doing a strpos search for ALTER, CREATE and DROP which should work.

Are there any other commands that do the things above and that I should include in my search?

Note that I don't need this for security reasons. I just need to know if the table schema changed, so I can update my local cache of the schema info...

like image 966
Alex Avatar asked Jan 18 '26 09:01

Alex


1 Answers

For some DBMS (PostgreSQL, MS SQL Server, Informix) SELECT ... INTO ... can create a new table.