我想创建一个存储来自两个不同的表值的表格;
从表1:的cust_id(VARCHAR2),invoice_amt(浮点)
从表2:的cust_id(来自表1),PAYMENT_DATE
我的表应该有3个字段:
cust_id, invoice_amt, payment_date
我尝试以下,这显然是错误的。
create table temp1 as (
select table_1.cust_id, table_1.invoice_amt, table_2.payment_date
from table_1@dblink, table_2@dblink)
您的宝贵建议将有很大的帮助。
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
)
我不是预言的人,但应该做你想做的(未经测试,虽然)。
你接近:
create table temp1 as (
select t1.cust_id, t1.invoice_amt, t2.payment_date
from table_1@dblink t1, table_2@dblink t2
where t1.cust_id=t2.cust_id)
这取决于你要使用它的话,但我会非常想使用视图,而不是一个表:
create view temp1(cust_id, invoice_amt, payment_date) as
select t1.cust_id, t1.invoice_amt, t2.payment_date
from table_1@dblink as t1 inner join table_2@dblink as t2
on t1.cust_id = t2.cust_id
其优点是它总是包含TABLE_1和TABLE_2当前版本的值。 缺点是,你不能编辑视图(或者,如果可以的话,你的编辑会影响基础表和视图)。