问题描述
unload to file1 select * from table1
除了这个糟糕的解决方案之外:
unload to file1 select * Title1table union select * from table1
解决方法
无法使用标准Informix工具将列名放入已卸载数据的第一行。
您最好的选择是使用我的sqlcmd
程序。您可以在IIUG — International Informix Users Group的Software Repository网站上找到它。有了它,你会写:
sqlcmd -d yourdb -H -e 'unload to file1 select * from table1'
,您将获得一行带有列标题(-H
)的行,另一行具有UNLOAD格式。您也可以添加-T
来获取列类型信息,在名称后的第二行(如果要求同时输入)。名称和类型均为UNLOAD格式。
sqlcmd -d stores -HT -e 'unload to "elements.unl" select * from elements'
输出的前七行是:
atomic_number|symbol|name|atomic_weight|pt_period|pt_group|stable|
INTEGER|CHAR(3)|CHAR(20)|DECIMAL(8,4)|SMALLINT|CHAR(2)|CHAR(1)|
1|H|Hydrogen|1.0079|1|1|Y|
2|He|Helium|4.0026|1|18|Y|
3|Li|Lithium|6.9410|2|1|Y|
4|Be|Beryllium|9.0122|2|2|Y|
5|B|Boron|10.8110|2|13|Y|