如何在sqlldr ctl文件中设置主键?

时间:2017-05-18 07:51:32

标签: java sql oracle sql-loader

这里我有以下文件

load data
infile 'emp.csv'
into table EMPLOYEES
append
fields terminated by ',' 
optionally ENCLOSED BY '"'
TRAILING NULLCOLS
(
TENANTID,
EMPLOYEEID,
ISEMPLOYEEACTIVE,
PASSWORD,
EMPLOYEEMANAGERID,
FIRSTNAME,
LASTNAME,
MIDDLENAME,
EMPLOYEEEMAILID,
EMPLOYEEASSISTANTID ,
CATEGORYID,
EMPLOYEENATIONALITY,
BRANCHID ,
GRADEID ,
PASSWORDRESETTOKEN,
PASSWORDRESETCREATEDATE,
ISBRANCHHEAD ,
DEFAULTCOSTCODE ,
GENDER 
)
此文件中的

EMPLOYEEID是主键,因此如何将该列设置为主键... 因为每次都需要唯一且自动生成的数字

这里是我的emp.csv文件

1006,1,0,saasas,1049,LoadData,lol,lol,bhargav121@gmail.com,1049,1125,India,2192,1128,1,1,1,1051,m

1 个答案:

答案 0 :(得分:3)

在db中。 create sequence EMPLOYEES_SEQ

在ctlfile中

...
TENANTID,
EMPLOYEEID "EMPLOYEES_SEQ.NEXTVAL",
ISEMPLOYEEACTIVE,
...