Oracle創(chuàng)建表分區(qū)的方法有兩種:手動分區(qū)和自動分區(qū)。
以下是一個示例創(chuàng)建表時的手動分區(qū)語法:
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),
...
);
以下是一個示例創(chuàng)建表時的自動分區(qū)語法:
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),
...
)
);
注意:自動分區(qū)需要在數(shù)據(jù)庫中啟用分區(qū)功能,并且需要分區(qū)表空間的支持。