Documentation Home
MySQL Shell 9.5
Download this Manual
PDF (US Ltr) - 2.5Mb
PDF (A4) - 2.5Mb


5.7 Output Formats

MySQL Shell can print results in table, tabbed, or vertical format, or as pretty or raw JSON output. The MySQL Shell configuration optionresultFormat can be used to specify any of these output formats as a persistent default for all sessions, or just for the current session. Changing this option takes effect immediately. For instructions to set MySQL Shell configuration options, seeSection 14.4, “Configuring MySQL Shell Options”. Alternatively, the command line option--result-format or its aliases (--table,--tabbed,--vertical) can be used at startup to specify the output format for a session. For a list of the command line options, seeSection A.1, “mysqlsh — The MySQL Shell”.

If theresultFormat configuration option has not been specified, when MySQL Shell is in interactive mode, the default format for printing a result set is a formatted table, and when MySQL Shell is in batch mode, the default format for printing a result set is tab separated output. When you set a default using theresultFormat configuration option, this default applies in both interactive mode and batch mode.

The MySQL Shell functionshell.dumpRows() can format a result set returned by a query in any of the output formats supported by MySQL Shell, and dump it to the console. (Note that the result set is consumed by the function.)

To help integrate MySQL Shell with external tools, you can use the--json option to control JSON wrapping for all MySQL Shell output when you start MySQL Shell from the command line. When JSON wrapping is turned on, MySQL Shell generates either pretty-printed JSON (the default) or raw JSON, and the value of theresultFormat MySQL Shell configuration option is ignored. When JSON wrapping is turned off, or was not requested for the session, result sets are output as normal in the format specified by theresultFormat configuration option.