If you connect to MariaDB using the command line interface, you might sometimes find that your query results are too wide, due to the number of columns being returned, and the data they contain.
Set the --auto-vertical
Option
To get MariaDB to automatically switch to vertical output mode whenever the result set is wider than the terminal width, use the --auto-vertical
option when launching MariaDB.
Like this:
mariadb --auto-vertical-output
That’s all.
Now when your results are too wide for the terminal, they will be output vertically.
Example
Suppose we do a query like this:
SELECT
BIN(1) AS '1',
BIN(2) AS '2',
BIN(3) AS '3',
BIN(4) AS '4',
BIN(5) AS '5',
BIN(6) AS '6',
BIN(7) AS '7',
BIN(8) AS '8',
BIN(9) AS '9',
BIN(10) AS '10';
Here are the results using vertical output:
1: 1 2: 10 3: 11 4: 100 5: 101 6: 110 7: 111 8: 1000 9: 1001 10: 1010
In this case, my terminal width was quite narrow, and so this caused the results to be displayed vertically.
If I widen my terminal and run the query again, they are output horizontally:
SELECT
BIN(1) AS '1',
BIN(2) AS '2',
BIN(3) AS '3',
BIN(4) AS '4',
BIN(5) AS '5',
BIN(6) AS '6',
BIN(7) AS '7',
BIN(8) AS '8',
BIN(9) AS '9',
BIN(10) AS '10';
Result:
+------+------+------+------+------+------+------+------+------+------+ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | +------+------+------+------+------+------+------+------+------+------+ | 1 | 10 | 11 | 100 | 101 | 110 | 111 | 1000 | 1001 | 1010 | +------+------+------+------+------+------+------+------+------+------+
That’s the same result we’d get if we didn’t have the --auto-vertical
option set.