Oracle創建表分區的方法有兩種:手動分區和自動分區。
以下是一個示例創建表時的手動分區語法:
CREATE TABLE table_name (
column1 data_type,
column2 data_type,
...
)
PARTITION BY RANGE (partition_key)
(
PARTITION partition_name1 VALUES LESS THAN (value1),
PARTITION partition_name2 VALUES LESS THAN (value2),
...
);
以下是一個示例創建表時的自動分區語法:
CREATE TABLE table_name (
column1 data_type,
column2 data_type,
...
)
PARTITION BY RANGE (partition_key)
SUBPARTITION BY HASH (subpartition_key)
SUBPARTITIONS 4
STORE IN (tablespace_name)
(
PARTITION BY RANGE (partition_key) INTERVAL (interval_value)
(
SUBPARTITION partition_name1 VALUES LESS THAN (value1),
SUBPARTITION partition_name2 VALUES LESS THAN (value2),
...
)
);
注意:自動分區需要在數據庫中啟用分區功能,并且需要分區表空間的支持。