如果一个表按月分区,并且在从上个月的15日到当月的15日检索数据时会出现任何错误,因为数据分布在两个不同的分区中。
答案 0 :(得分:2)
蹩脚的面试问题,但答案是否定的,即你可以在没有任何问题的情况下跨越分区:
SQL> create table t ( x date )
2 partition by range ( x )
3 (
4 partition p1 values less than ( date '2018-05-01' ),
5 partition p2 values less than ( date '2018-06-01' ),
6 partition p3 values less than ( date '2018-07-01' )
7 );
Table created.
SQL>
SQL> insert into t
2 select date '2018-04-01'+ rownum
3 from dual
4 connect by date '2018-04-01'+ level < date '2018-07-01';
90 rows created.
SQL>
SQL> select count(*) from t partition ( p1 ) ;
COUNT(*)
----------
29
1 row selected.
SQL> select count(*) from t partition ( p2 ) ;
COUNT(*)
----------
31
1 row selected.
SQL> select count(*) from t partition ( p3 ) ;
COUNT(*)
----------
30
1 row selected.
SQL>
SQL> select count(*)
2 from t
3 where x between date '2018-05-15' and date '2018-06-15';
COUNT(*)
----------
32