20151118
主题:查询数据库的库表信息
(来自MySQL reference manual 3.4)
=============================================
获取建表语句
show create table tab_name;
获取表的索引信息
show index from tab_name;
主题:msyql批处理
(来自MySQL reference manual 3.5)
=============================================
说明:bat-file为批处理命令集
#mysql < bat-file;
#mysql -e "source bat-file";
#mysql -u user -h host -p < bat-file;
分页输出
#mysql < bat-file|more;
结果保存到文件
#mysql < bat-file > mysql.out;
如果你想在批处理模式下获得交互式处理的结果,可以加选项 -t;
显示详细结果用-vvv选项;
可以这样执行脚本
mysql> source filename;
mysql> \. filename
测量批处理执行时间
# at start of your script file
SET @start=UNIX_TIMESTAMP();
# great job
...
...
...
# at bottom of your script file
SET
@s=@seconds:=UNIX_TIMESTAMP()-@start,
@d=TRUNCATE(@s/86400,0), @s=MOD(@s,86400),
@h=TRUNCATE(@s/3600,0), @s=MOD(@s,3600),
@m=TRUNCATE(@s/60,0), @s=MOD(@s,60),
@day=IF(@d>0,CONCAT(@d,' day'),''),
@hour=IF(@d+@h>0,CONCAT(IF(@d>0,LPAD(@h,2,'0'),@h),' hour'),''),
@min=IF(@d+@h+@m>0,CONCAT(IF(@d+@h>0,LPAD(@m,2,'0'),@m),' min.'),''),
@sec=CONCAT(IF(@d+@h+@m>0,LPAD(@s,2,'0'),@s),' sec.');
SELECT
CONCAT(@seconds,' sec.') AS seconds,
CONCAT_WS(' ',@day,@hour,@min,@sec) AS elapsed;
阅读(613) | 评论(0) | 转发(0) |