oracle partition分割槽_分割槽列為空測試(一)

wisdomone1發表於2013-01-06
  1  create table t_partition(a int,b int)
  2  partition by range(a)
  3  (partition p1 values less than (10),
  4   partition p2 values less than (maxvalue)
  5* )
13:36:09 SQL> /
Table created.
Elapsed: 00:00:00.24

Elapsed: 00:00:00.02
13:36:27 SQL> insert into t_partition values(null,1);
1 row created.
Elapsed: 00:00:00.01
13:36:33 SQL> insert into t_partition values(1,1);
1 row created.
Elapsed: 00:00:00.00
13:36:40 SQL> insert into t_partition values(12,1);
1 row created.
Elapsed: 00:00:00.00
13:36:43 SQL> commit;
Commit complete.
Elapsed: 00:00:00.00
13:36:45 SQL> select * from t_partition;
         A          B
---------- ----------
         1          1
                    1
        12          1
Elapsed: 00:00:00.01
13:36:49 SQL> select table_name,partition_name,num_rows from user_tab_partitions
 where table_name='T_PARTITION';
TABLE_NAME                     PARTITION_NAME                   NUM_ROWS
------------------------------ ------------------------------ ----------
T_PARTITION                    P1
T_PARTITION                    P2
Elapsed: 00:00:00.26

Elapsed: 00:00:00.13
13:37:52 SQL> exec dbms_stats.gather_table_stats(user,'t_partition');
PL/SQL procedure successfully completed.
Elapsed: 00:00:03.33
13:38:03 SQL> select table_name,partition_name,num_rows from user_tab_partitions
 where table_name='T_PARTITION';
TABLE_NAME                     PARTITION_NAME                   NUM_ROWS
------------------------------ ------------------------------ ----------
T_PARTITION                    P1                                      1
T_PARTITION                    P2                                      2
Elapsed: 00:00:00.05
13:38:06 SQL> select * from t_partition partition(p1);
         A          B
---------- ----------
         1          1
Elapsed: 00:00:00.04
13:38:37 SQL> select * from t_partition partition(p2);
         A          B
---------- ----------
                    1
        12          1
Elapsed: 00:00:00.00
13:38:40 SQL>
小結:分割槽鍵為空,此行記錄歸屬於最後一個發區

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-752191/,如需轉載,請註明出處,否則將追究法律責任。

相關文章