分区表SQL的别名

分区表SQL的别名,sql,oracle,Sql,Oracle,我试图连接2个表,其中两个表都是分区表。这需要时间,但输出结果不一致。它仅显示第一个表数据。是分区表的别名吗?我们如何使用分区表的别名???Yo没有从第二个表(t2)调用任何列。您可以按照下面的代码操作 select t1.col1, t1.col2, t1.col3, t1.col4, t1.col5 from (tab1.tab1_1 partition(p20191231)) t1 LEFT JOIN ( select t2.col_1 AS col_1,

我试图连接2个表,其中两个表都是分区表。这需要时间,但输出结果不一致。它仅显示第一个表数据。是分区表的别名吗?我们如何使用分区表的别名???

Yo没有从第二个表(t2)调用任何列。您可以按照下面的代码操作

select t1.col1, t1.col2, t1.col3, t1.col4, t1.col5

from (tab1.tab1_1 partition(p20191231)) t1 

LEFT JOIN ( 
            select t2.col_1 AS col_1, t2.col_2
            from (tab2.tab2_2  partition (p20191231)) t2
            where date between '1-Dec-2019' and '31-Dec-2019')
            ON t1.col1 = col_1
where 
        t1.col6 between '1-Dec-2019' AND '31-Dec-2019';
甚至简化为

select t1.col1, t1.col2, t1.col3, t1.col4, t1.col5,t2.col_1,t2.col_2
from tab1.tab1_1 partition(p20191231) t1 
LEFT JOIN ( 
            select t2.col_1 AS col_1, t2.col_2
            from (tab2.tab2_2  partition (p20191231)) t2
            where date between '1-Dec-2019' and '31-Dec-2019') t2
            ON t1.col1 = col_1
where 
        t1.col6 between '1-Dec-2019' AND '31-Dec-2019';

Yo没有调用第二个表(t2)中的任何列。您可以按照下面的代码操作

select t1.col1, t1.col2, t1.col3, t1.col4, t1.col5

from (tab1.tab1_1 partition(p20191231)) t1 

LEFT JOIN ( 
            select t2.col_1 AS col_1, t2.col_2
            from (tab2.tab2_2  partition (p20191231)) t2
            where date between '1-Dec-2019' and '31-Dec-2019')
            ON t1.col1 = col_1
where 
        t1.col6 between '1-Dec-2019' AND '31-Dec-2019';
甚至简化为

select t1.col1, t1.col2, t1.col3, t1.col4, t1.col5,t2.col_1,t2.col_2
from tab1.tab1_1 partition(p20191231) t1 
LEFT JOIN ( 
            select t2.col_1 AS col_1, t2.col_2
            from (tab2.tab2_2  partition (p20191231)) t2
            where date between '1-Dec-2019' and '31-Dec-2019') t2
            ON t1.col1 = col_1
where 
        t1.col6 between '1-Dec-2019' AND '31-Dec-2019';

我可以看到这里使用的两个分区都有相同的名称。这是一个错误还是故意的?故意的,tab1.tab1_1分区(p20191231),tab2.tab2_2分区(p20191231)是两个不同的表相同日期分区。我可以看到这里使用的两个分区都有相同的名称。这是错误还是故意的?故意的,tab1.tab1_1分区(p20191231),tab2.tab2_2分区(p20191231)是两个不同的表相同日期分区。