如何在 Informix 中向 select 结果添加一个额外的假空列?
How to add an additional fake null column to select result in Informix?
我需要 select 当前 table 中不存在的附加列,以便以正确的格式卸载数据。
假设我有两个不同的table如下。
**
tab1
----
col1 col2 col3
tab2
---
col1 col2
**
假设我需要从 tab2 中卸载 1000 条记录并需要将它们加载到 tab1 中。但是在考虑列数时存在不匹配。但是我可以在将数据加载到 tab1
时为 col3 输入空值
所以我的卸载命令如下
unload to data.unl select col1, col2, null as col3 from tab2;
然后我可以将data.unl
的内容加载到tab1中。但我的问题是当我试图以这种方式卸载数据时出现语法错误。请纠正我。有人可能会争辩说我可以使用一个简单的插入命令 selecting 来自 tab2 的数据。但是在我的实际用例中是不可能的,因为数据量太大了,我希望使用 ipload
.
这是我的示例错误:
nwn@nwnhost$ echo "select CURRENT as col1,null as col2 from sysdual" | dbaccess sysmaster
Database selected.
201: A syntax error has occurred.
Error in line 1
Near character position 29
Database closed.
将 NULL
转换为所需的类型:
SELECT CURRENT AS col1, NULL::INTEGER AS col2
FROM sysmaster:"informix".sysdual;
我需要 select 当前 table 中不存在的附加列,以便以正确的格式卸载数据。
假设我有两个不同的table如下。
**
tab1
----
col1 col2 col3
tab2
---
col1 col2
**
假设我需要从 tab2 中卸载 1000 条记录并需要将它们加载到 tab1 中。但是在考虑列数时存在不匹配。但是我可以在将数据加载到 tab1
时为 col3 输入空值所以我的卸载命令如下
unload to data.unl select col1, col2, null as col3 from tab2;
然后我可以将data.unl
的内容加载到tab1中。但我的问题是当我试图以这种方式卸载数据时出现语法错误。请纠正我。有人可能会争辩说我可以使用一个简单的插入命令 selecting 来自 tab2 的数据。但是在我的实际用例中是不可能的,因为数据量太大了,我希望使用 ipload
.
这是我的示例错误:
nwn@nwnhost$ echo "select CURRENT as col1,null as col2 from sysdual" | dbaccess sysmaster
Database selected.
201: A syntax error has occurred.
Error in line 1
Near character position 29
Database closed.
将 NULL
转换为所需的类型:
SELECT CURRENT AS col1, NULL::INTEGER AS col2
FROM sysmaster:"informix".sysdual;