When I first heard of MySQL, it was still something of a toytown database. No stored procedures, no database replication, and many other issues. Times have moved on since then, and yet I forget to allow my view to develop.
So, it is a pleasant surprise to find these two tiny mysql features that have made my life vastly simpler:
pager less
At the mysql prompt, you can enter a select statement, the results of which fill more than one screenful. This can be a pain, especially if your terminal's buffer isn't of sufficient size to store the entire output. Or, if your terminal buffer contains output from previous queries, and it can be hard to spot where one ends and the next begins. And, you can't do mysql | less because it is an interactive program.
I discovered last week that all you need to do is type:
pager less
And all queries will be paged through Unix less. Fantastic!
FROM_UNIXTIME()
I had a table that was storing timestamps in Unix 'seconds since epoch' format. Makes sense from a design point of view, but it is a real pain when debugging from the mysql prompt, because 1232011129 doesn't mean much to me.
Well FROM_UNIXTIME() comes to the rescue. In a table with an 'updated' date in unix format, I can do:
SELECT updated, FROM_UNIXTIME(updated) FROM mytable;
And hey presto, I have human readable versions of my Unix format timestamps.