Large data tables in the Oracle database are partitioned to improve data reading efficiency:
In PLSQL, directly add the Code:
-- Purpose: to partition and convert large table data. In this example, only 5000 pieces of data are used;
-- Create Table T
Create table t (id number, name varchar2 (10 ));
Insert into t select rownum + 4, '1, 5000, 4' from dual connect by rownum <=;
Commit;
Select count (1) from t;
-- Create a tablespace
Create tablespace ts_1 datafile 'e: \ oracle \ product \ 10.2.0 \ oradata \ orcl \ ts_1.dbf' size 50 m reuse;
Create tablespace ts_2 datafile 'e: \ oracle \ product \ 10.2.0 \ oradata \ orcl \ ts_2.dbf' size 50 m reuse;
Create tablespace ts_3 datafile 'e: \ oracle \ product \ 10.2.0 \ oradata \ orcl \ ts_3.dbf' size 50 m reuse;
-- Create a new table and partition
Create table t_new partition by range (id )(
Partition p1 values less tha (2000) tablespace ts_1,
Partition p2 values less than (4000) tablespace ts_2,
Partition p3 values less than (maxvalue) tablespace ts_3)
As select * from t;
-- Delete the old table and change its name
Truncate table t;
Drop table t;
Alter table t_new rename to t;
-- Check the data of each partition
Select count (*) from t partition (p1 );
Select count (*) from t partition (p2 );
Select count (*) from t partition (p3 );