Friday, October 17, 2008

Prompt prompts

Ever wonder how long that MySQL statement took to run? Or what pace those scripts you run from cron take to run at night? You can change the prompt on the MySQL command-line tool to show user name, time, current database or many other useful facts.


>mysql foo
mysql> prompt \R:\m:\s>
PROMPT set to '\R:\m:\s>'
14:11:16>SHOW TABLES;
+------+
| foo |
| bar |
+------+
2 rows in set (0.01 sec)

14:12:12>



I find this quiet handy in scripts that I run late at night. It is also good when running a complex statement that will consume clock time so that I can tell when it finished. Not exactly awe inspiring but a quite handy 'trick'.



Details are here half way down the page.

1 comment:

Ghenghy said...

Thank you for posting this. Definitely a useful little thing to know. Pity I didn't read this before I started a long-running update earlier today. I just can't recall what time I started it.