一个SQL如何选择多个分区? [英] How does one do a SQL select over multiple partitions?

查看:807
本文介绍了一个SQL如何选择多个分区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有比以下更有效的方法?

Is there a more efficient way than:

select * from transactions partition( partition1 ) 
union all 
select * from transactions partition( partition2 ) 
union all 
select * from transactions partition( partition3 ); 

推荐答案

在查询中使用PARTITION(partitionN)语法应该很少见.

It should be exceptionally rare that you use the PARTITION( partitionN ) syntax in a query.

您通常只想为分区键指定值,并允许Oracle执行分区消除.例如,如果您的表是根据TRANSACTION_DATE每天进行分区的,则为

You would normally just want to specify values for the partition key and allow Oracle to perform partition elimination. If your table is partitioned daily based on TRANSACTION_DATE, for example

SELECT *
  FROM transactions
 WHERE transaction_date IN (date '2010-11-22', 
                            date '2010-11-23', 
                            date '2010-11-24')

将从今天的分区,昨天的分区和前一天的分区中选择所有数据.

would select all the data from today's partition, yesterday's partition, and the day before's partition.

这篇关于一个SQL如何选择多个分区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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