(1)SQL示例如下,要将如下的SQL查询结果导出到一个txt文件,便于研发做结果内容的核对
select
ps_partkey,
sum(ps_supplycost * ps_availqty) as value
from
partsupp,
supplier,
nation
where
ps_suppkey = s_suppkey
and s_nationkey = n_nationkey
and n_name = 'GERMANY'
group by
ps_partkey having
sum(ps_supplycost * ps_availqty) > (
select
sum(ps_supplycost * ps_availqty) * 0.0000010000
from
partsupp,
supplier,
nation
where
ps_suppkey = s_suppkey
and s_nationkey = n_nationkey
and n_name = 'GERMANY'
)
order by
value desc;
(2)将如上SQL结果导出的方法
1、新建一个SQL文件,命名为c.sql
2、在存放c.sql的目录下执行如下的命令,注意更换自己数据库的相关信息
mysql -h192.168.30.118 -P3001 -uroot -pAa123456 tpch_syw <c.sql >query_11_result.text
作者:Syw