0

我有一个人的excel表,每个人都有一个父亲和一个母亲在同一个人表中。我的 exel 表如下所示:

---父亲 --- 母亲

约翰--------托尼-----简

托尼--------杰克

我想将数据导入到如下所示的 Oracle 数据库表中:

id --- 人 ---父亲 --- 母亲

0 -----插孔

1 -----托尼-------- 0

2 -----简

我的工作流程应该是什么?

3 ----约翰 -------- 1------------2

4

1 回答 1

0

至少从将数据加载到具有代理 ID 的表中开始会更容易:

people father mother
------ ------ ------
john   tony   jane
tony   jack

然后,您可以为尚未在“人”列中的父亲和母亲添加行:

insert into mytable (people)
( select mother from mytable
  union
  select father from mytable 
)
minus
select people from mytable;

这会给你:

people father mother
------ ------ ------
jack
tony   jack
jane
john   tony   jane

然后,您可以为每一行添加一个代理 ID,并在需要时使用它。

于 2011-06-16T12:51:56.660 回答