简体   繁体   English

如何将表数据导出到txt(或)csv文件? 仅最后查询结果集导出到文件中?

[英]How to export table datas to txt(or)csv files? Only Last query resultsets got exported into file?

I am new Bash shell script and exporting the table datas into txt file. 我是新的Bash Shell脚本,并将表数据导出到txt文件中。

db2 "export to $filename of del messages msg.txt select * from students_table" 

file Contains "FirstName","23","Pass" 文件包含“名字”,“ 23”,“通过”

Again i am using the same file name 我再次使用相同的文件名

$filename $文件名

 db2 "export to $filename of del messages msg.txt select * from employees_table"

Now the output is "EmployeeName","25,000","Salaried" Only last query result set got printed. 现在输出为“ EmployeeName”,“ 25,000”,“ Salaried”仅打印了最后一个查询结果集。

Expected Output is 预期输出为

  1. "FirstName","23","Pass" “名字”, “23”, “通行证”
  2. "EmployeeName","25,000","Salaried" “EmployeeName”, “25,000”, “工作人员”

help me to resolve this. 帮助我解决这个问题。 thanks in advance. 提前致谢。

EXPORT command overwrites the file if it exists: EXPORT命令将覆盖文件(如果存在):

TO filename 到文件名

... ...

If the name of a file that exists is specified, the export utility overwrites the contents of the file; 如果指定了存在的文件名,则导出实用程序将覆盖文件内容;否则,导出实用程序将覆盖该文件的内容。 it does not append the information. 它不附加信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM