我写了下面的脚本来从数据库中选择数据,并使用isql将其保存在csv文件中:
OUTPUT temp/filename.csv FORMAT csv DELIMITED BY ';';
SELECT dept_no, department, location FROM department;
我在csv文件中得到了以下结果:
DEPT_NO DEPARTMENT LOCATION
======= ========================= ===============
000 Corporate Headquarters Monterey
100 Sales and Marketing San Francisco
600 Engineering Monterey
900 Finance Monterey
180 Marketing San Francisco
620 Software Products Div. Monterey
621 Software Development Monterey
622 Quality Assurance Monterey
623 Customer Support Monterey
670 Consumer Electronics Div. Burlington, VT
671 Research and Development Burlington, VT
672 Customer Services Burlington, VT
130 Field Office: East Coast Boston
140 Field Office: Canada Toronto
110 Pacific Rim Headquarters Kuaui
115 Field Office: Japan Tokyo
116 Field Office: Singapore Singapore
120 European Headquarters London
121 Field Office: Switzerland Zurich
123 Field Office: France Cannes
DEPT_NO DEPARTMENT LOCATION
======= ========================= ===============
125 Field Office: Italy Milan
然而,我需要得到一个输出1)没有重复的标题和2)没有列中数据之间的空间。
理想的输出应该是这样的:
ID;LASTNAME;FIRSTNAME;DOB
1;Miller;Steve;1980-06-28
2;Jones;Martha;1965-11-02
3;Waters;Richard;1979-10-15
有人能帮我解决这个问题吗?先谢谢你了😊
2条答案
按热度按时间ou6hu8tu1#
这会对你有所帮助。它使isql在每个
5vf7fwbs2#
您可以添加一个串联a ';'到select中的每个字段(当然最后一个除外),如select(fieldname)||';'作为xxxxx,(fieldname)||“;”作为xxxxx........
(标题仍然是一个字段)
1;米勒;Steve;1980-06-28 2;琼斯玛莎1965-11-02 3;沃茨;理查德;1979-10-15