3

Is it possible to modify the string used to delimit output columns in command line MySQL query results? E.g. could I change | to ! or ||?

2

According to the manual (on linux man mysql) starting mysql with -s -r options will change your queries from

% mysql
mysql> SELECT CHAR(92);
+----------+
| CHAR(92) |
+----------+
| \        |
+----------+

to

% mysql -s -r
mysql> SELECT CHAR(92);
CHAR(92)
\
0

Yes. From mysql documentation:

[mysql commandline] When used interactively, query results are presented in an ASCII-table format. When used noninteractively (for example, as a filter), the result is presented in tab-separated format. The output format can be changed using command options.

Thus, you can pipe mysql commandlines output to sed and change tabs to whatever you want.

see sed doc: http://www.grymoire.com/Unix/Sed.html#uh-6

also there seems to be a patch to add that option explicitly: http://bugs.mysql.com/bug.php?id=8904

1
  • Those are both good suggestions, but sadly they don't fit my needs. the first one because I want to work in interactive mode. And the second because I can not currently put the time into this. I was more looking for a built in solution but it seems that currently there is non. so I will continue reading my Hebrew from left to right :)
    – epeleg
    Mar 10 '11 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.