Encouraged by Baron Schwartz tip on result set comparison, here are a few more, on
the same vein.
First, you can send a result set to a file. Probably you
will say "yeah, I know, using SELECT INTO OUTFILE". Correct.
Except that you can't rewrite to an existing file, if you want
to, and you will get a raw output, not the well formatted one
that you usually see on the command line. For example:
mysql > select 1 into outfile '/tmp/f1.txt';
mysql > \! cat /tmp/f1.txt
1
mysql > select 1 into outfile '/tmp/f1.txt';
ERROR 1086 (HY000): File '/tmp/f1.txt' already exists
BTW, \! command
is a handy shortcut for executing a
shell command.
Let's see what happens with the alternative …