SQL 加载数据 INFILE 但保持一个字段静态

SQL LOAD DATA INFILE but keep one field static

我在运行下面加载数据成table

OPTIONS (Skip=1)
LOAD DATA
INFILE 'D:\EPM\import\test.txt' 
APPEND
INTO TABLE HYP.HS_MEMBER_D
FIELDS TERMINATED BY "|" 
TRAILING NULLCOLS
(
DIMENSION,
PARENT,
CHILD,
ALIAS,
ATTRB01
)

这工作正常,但我想将 ATTRB01 字段保留为静态值,我想为所有记录加载 "Alloc",此脚本中有没有办法加载静态值,即使我正在从文件加载其他字段?

尝试使用 set at end

OPTIONS (Skip=1)
LOAD DATA
INFILE 'D:\EPM\import\test.txt' 
APPEND
INTO TABLE HYP.HS_MEMBER_D
FIELDS TERMINATED BY "|" 
TRAILING NULLCOLS
(
DIMENSION constant Account,
PARENT,
CHILD,
ALIAS,
ATTRB01
)
set ATTRB01='default_value'

你会加载一个常量,例如

OPTIONS (Skip=1)
LOAD DATA
INFILE 'D:\EPM\import\test.txt' 
APPEND
INTO TABLE HYP.HS_MEMBER_D
FIELDS TERMINATED BY "|" 
TRAILING NULLCOLS
(
DIMENSION constant Account,
PARENT,
CHILD,
ALIAS,
ATTRB01  constant 'Alloc'       --> this
)

这是一个例子:测试table:

SQL> desc test
 Name                                      Null?    Type
 ----------------------------------------- -------- -------------
 ID                                                 NUMBER
 ATTRB01                                            VARCHAR2(20)

控制文件:

load data 
infile *
replace
into table test
fields terminated by ","
trailing nullcols
(
id,
attrb01 constant 'Alloc'
)

begindata
1,xxx
2,yyy
3,zzz

正在加载会话和结果:

SQL> $sqlldr scott/tiger control=test01.ctl log=test01.log

SQL*Loader: Release 11.2.0.2.0 - Production on Sri Kol 15 21:08:59 2018

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Commit point reached - logical record count 2
Commit point reached - logical record count 3

SQL> select * From test;

        ID ATTRB01
---------- --------------------
         1 Alloc
         2 Alloc
         3 Alloc