水壶/自动参考表

发布于 2024-11-15 20:33:43 字数 498 浏览 10 评论 0原文

我有一张包含人员的 Excel 表,每个人都有一个父亲和一个母亲,位于同一个人员表中。我的 exel 表看起来像这样:

poeple --- father --- mother

john -------- tony --- -- jane

tony -------- jack

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

id --- poeple -- - 父亲 --- 母亲

0 -----杰克

1 -----tony-------- 0

2 -----jane

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

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

I have an excel sheet with poeple, each people has a father and a mother that is in the same poeple sheet. My exel table looks like that :

poeple --- father --- mother

john -------- tony ----- jane

tony -------- jack

I would like to import the datas to an Oracle database table that look like :

id --- poeple --- father --- mother

0 -----jack

1 -----tony-------- 0

2 -----jane

what should be my workflow ?

3 ----john -------- 1-----------2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫罗兰の梦幻 2024-11-22 20:33:43

至少首先将数据加载到具有代理 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 并在需要时使用它。

It would be easier to at least start by loading the data into a table with the surrogate ID:

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

Then you can add rows for the fathers and mothers not already in the "people" column:

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

That will give you:

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

You can then add a surrogate ID for each row and use that instead, if you need it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文