Cal*_*ney 6 sql oracle syntax select partitioning
我想查询一张名为'FooBar'的客户有一百万条记录的表,其记录日期为2016年12月7日.该表中有10天的数据.
select *
from table
where customer = 'FooBar'
and insert_date between to_date('2016-07-24 00:00:00', 'YYYY-MM-DD HH24:MI:SS') and to_date('2016-07-24 23:59:59', 'YYYY-MM-DD HH24:MI:SS');
Run Code Online (Sandbox Code Playgroud)
上面的查询的问题是它需要一段时间才能运行.我希望它运行得更快.
该表分为24小时.我可以将查询集中在表分区上吗?这会使查询运行得更快吗?
select *
from partition-7-24-2016
where customer = 'FooBar';
Run Code Online (Sandbox Code Playgroud)
Mur*_*nik 16
正确的语法是select [columns] from [table] partition ([partition]).所以,在这个用例中,你会有这样的东西:
SELECT *
FROM mytable PARTITION (partition_7_24_2016)
WHERE customer = 'FooBar';
Run Code Online (Sandbox Code Playgroud)