1.实现TAB键补全
SHELL>vi /etc/my.cnf
[mysql]
#no-auto-rehash
auto-rehash
SHELL>reboot mysqld
note: 1.要先use到某个数据库下;2.要补全的关键字需要大写。
2.prompt让操作更加清楚
mysql>prompt /u@/h(/d) /r:/m:/s (临时)
[mysql] (长久)
prompt=//u@//h
3.pager让浏览更从容
mysql>pager less | pager more
mysql>nopager
4.timestamp与unixtime之间的转换
unix_timestamp ------ from_unixtime
1270716930 -----> 2010-04-08 16:55:30
5.binary让字串比较是区分大小写
6.group by with rollup 统计总共记录数,最后一条记录为总数
7.group_concat让记录在一行显示
mysql> select group_concat(title separator ',') from tjob;
+----------------------------------------+
| group_concat(title separator ',') |
+----------------------------------------+
| 11,22,33,aa,bb,cc,AA,BB,CC |
+----------------------------------------+
1 row in set (0.00 sec)
8.order by if 排序时将某列中特定值排在最前,例如我在排序中要把aa放在最前面:
select title from tjob order by if(title='aa',0,1),title;
+-------+
| title |
+-------+
| aa |
| AA |
| 11 |
| 22 |
| 33 |
| bb |
| BB |
| cc |
| CC |
+-------+
MySQL客户端命令行应用技巧
最新推荐文章于 2024-10-23 09:30:00 发布