How does MySql figure out that its output is being captured to a file?

Viewed 21

If suppose I execute this:

mysql -umyuserid -pmypassword -hmymachine -e "select * from mytable;"

I will get my rows with borders drawn with |, - etc However, the same command when redirected to a file will get me something like a tab delimited output

mysql -umyuserid -pmypassword -hmymachine -e "select * from mytable;" > mydata.csv

This resultant file can be opened in a spreadsheet program

So my question -- how does it do it, and why was it so worth their while to do it?

1 Answers
Related