I'm making a simple tool that will get a string of MySQL commands and run it on several DB servers sequentially. I trust the users to be sensible, but mistakes happen. I'm wondering:
Is there a way to validate, at runtime, (relatively simple) MySQL queries to see if they're syntactically correct?
In other words,
SELECT * FROM x;
or
INSERT INTO x SET id=1,bar="foo";
would be marked valid, whereas any of those would not:
SELECT FROM x;
SECLET * RFOM x;
ISNETR INTO x SET id=1;
HJBGYGCRYTCY;
For SELECT
s, I could bend EXPLAIN
to my needs - run EXPLAIN SELECT (...)
and watch for errors, but is there a way to check for other commands as well? I'm searching MySQL docs and Google, so far no luck.
Thanks for any hints.
Edit: hopefully clarified a bit