oracle partition table
By judging the partition column, put different records into different partitions. Each partition is an independent segment
①range partition Use the column value range as the partition condition
create table test(id number,time date)partition by
range (time)(
partition p1 values less than (to_date('2010-10-01','yyyy-mm-dd')),
partition p2 values less than (maxvalue)
)
②hash partition
For those columns that cannot be effectively divided into ranges, hash partitioning can be used, and Oracle automatically distributes evenly based on the hash value of the column
create table test (id varchar2(256),time date) partition by
hash(id)(
partition p1 tablespace ts01,
partition p2 tablespace ts02
)
③list partition
The list partition must explicitly specify the column value, only one column can be specified but each partition value can be multiple. When the value of List partition is not inserted in the range of each partition, an error will be reported. Generally, a default partition should be created to store other values.
create table test(id varchar2(256),areacode varchar2(4))
partition by list(areacode)
(partition list_1 values('025'),
partition list_2 values('372'),
partition list_3 values(default)
)
Oracle 11g new feature interval automatically increases partitions
Data type selection for date storage in oracle
In the project, I see that the time is saved as date, timestamp, varchar2
date saves the year, month, day, hour, minute and second, timestamp is accurate to fractional seconds but the maximum value is only up to 2038
date is easy to compare and calculate between times, but sometimes it is not easy to compare the sequence of events when the precision is not enough.
The timstamp precision is enough, the maximum value is not enough, it is more troublesome to transfer and convert
varchar2 is easy to transmit and display, but it is more troublesome to compare and calculate time