使用来自2个不同表的字段创建表 [英] Creating tables with fields from 2 different tables

查看:82
本文介绍了使用来自2个不同表的字段创建表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个表来存储两个不同表中的值;

I want to create a table that stores values from two different tables;

从表1中开始:cust_id(varchar2),invoice_amt(浮动)

From table 1: cust_id (varchar2), invoice_amt (float)

从表2:付款日期(从表1),付款日期

From table 2: cust_id (from table 1), payment_date

我的表格应包含3个字段:

My table should have 3 fields:

cust_id, invoice_amt, payment_date

我尝试了以下方法,这显然是错误的.

I tried the following, which is obviously wrong.

create table temp1 as (
    select table_1.cust_id, table_1.invoice_amt, table_2.payment_date
      from table_1@dblink, table_2@dblink)

您的宝贵建议将有很大帮助.

Your valuable suggestions will be of great help.

推荐答案

create table temp1 as (
    select 
        table_1.cust_id,
        table_1.invoice_amt,
        table_2.payment_date 
    from 
        table_1@dblink, 
        table_2@dblink 
    where 
        table_1.cust_id = table_2.cust_id
    )

我不是甲骨文公司,但是那应该做您想要的(尽管未测试).

I'm no oracle guy, but that should do what you want (untested, though).

这篇关于使用来自2个不同表的字段创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆