Using the FILE TO option
When you execute a SET EXPLAIN FILE TO statement, explain output is turned on. The SET EXPLAIN FILE TO statement can change the default file name for the explain output until the end of the session or until another SET EXPLAIN statement is issued.
The filename can be any valid combination of path and file name. If no path component is specified, the file is placed in the default explain output location. The permissions for the file are owned by the current user.
The output file that you specify in the SET EXPLAIN statement can be a new file or an existing file. If the FILE TO clause specifies an existing file, the new output is appended to that file.