What is the equivalent of the spool command in MySQL?

rambokayambo picture rambokayambo · Jun 25, 2012 · Viewed 17.4k times · Source

I know you use the spool command when you are trying to write a report to a file in Oracle SQLplus.

What is the equivalent command in MySQL?

This is my code:

set termout off

spool ${DB_ADMIN_HOME}/data/Datareport.log @ ${DB_ADMIN_HOME}/Scripts.Datavalidation/Datareportscript.sql

spool off
exit

How can I write it in MySQL?

Answer

Zeta picture Zeta · Sep 6, 2017

In MySQL you need to use the commands tee & notee:

tee data.txt;
//SQL sentences...
notee;

teedata.txt == spooldata.txt

notee == spool off