将MySQL中sql运行结果保存到文件
有两种方法。
方法一:在mysql>提示符中使用tee
mysql> tee output.txt
Logging to file 'output.txt'
mysql> notee
Outfile disabled.
或者
mysql> \T output.txt
Logging to file 'output.txt'
mysql> \t
Outfile disabled.
这个类似于sqlplus的spool功能,可以将命令行中的结果保存到外部文件中。如果指定已经存在的文件,则结果会附加到文件中。
参考:http://www.ningoo.net
方法二:使用mysql命令行工具的--tee参数
$mysql --tee=ot.txt
Logging to file 'ot.txt'
mysql>
这回将所有的输入和输出内容都记录到指定的文件中(直到exit为止)。如果指定已经存在的文件,则结果会附加到文件中。
相关文档:
时间:2009-03-12 12:38:24 来源:Linux联盟
作者:
来源:it168.com
作者:田逸(sery@163.com)
俗话说:工欲善其事,必先利其器.要做好系统管理,使自己的工作更轻松更有效的话,一个好的监控工具是必不可少的了。在这里我向 ......
This is very common request recently – How to import CSV file into SQL Server? How to load CSV file into SQL Server Database Table? How to load comma delimited file into SQL Server? Let us see the solution in quick steps.
CSV stands for Comma Separated Values, sometimes also called Co ......
在SQL语句优化过程中,我们经常会用到hint,现总结一下在SQL优化过程中常见Oracle HINT的用法:
1. /*+ALL_ROWS*/
表明对语句块选择基于开销的优化方法,并获得最佳吞吐量,使资源消耗最小化.
例如:
SELECT /*+ALL+_ROWS*/ EMP_NO,EMP_NAM,DAT_IN from BSEMPMS WHERE EMP_NO=’SCOTT’;
2. /*+FIRST_ROWS*/
表 ......
cdate是datetime类型的字段
统计一年的如下
select datepart(yy,cdate) as '月份',sum(cmoney) from consumption group by datepart(yy,cdate)
统计一月的如下
select datepart(mm,cdate) as '月份',sum(cmoney) from consumption where datepart(yy,cdate)=2009 group by datepart(mm,cdate)
统计一周 ......
使用scott/tiger用户下的emp表和dept表完成下列练习,表的结构说明如下
emp员工表(empno员工号/ename员工姓名/job工作/mgr上级编号/hiredate受雇日期/sal薪金/comm佣金/deptno部门编号)
dept部门表(deptno部门编号/dname部门名称/loc地点)
工资 = 薪金 + 佣金
1.列出至少有一个员工的所有部门
2.列出薪金比& ......