toofishes.net

The MySQL Syntax Dartboard

It is angry blog post night, but writing about them is a great way to stop thinking about problems. Time to play MySQL darts:

SHOW GRANTS ...;
SHOW INDEXES ...;
SHOW CREATE TABLE ...;

SHOW and DESCRIBE tend to be the goto commands in MySQL for doing basic database diving in the command line shell.

Three points to you if you can complete all three statements without looking them up in the documentation or via Google, or making any syntax errors. Answers are a few paragraphs down so you can’t see them yet.

I’m going to ramble on here so the answers are hopefully more than a screen down.

Did you get it? Are you sure? Wouldn’t want you to experience something like

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near ''archweb'@'localhost'' at line 1

Don’t cheat!

Here are your answers.

SHOW GRANTS FOR 'archweb'@'localhost';
SHOW INDEXES FROM package_files;
SHOW CREATE TABLE package_files;

WTF, MySQL? Do you really find the need to use FOR, FROM, and the complete absence of a preposition in varying degrees across the multiple SHOW commands?

The full insanity is documented, and at least they had the state of mind to put a single table of all SHOW statements on the same page so you can see how horribly thought out their syntax planning was.

Tags

See Also