ORACLE about table partitions some maintenance operations

About table partitions some maintenance operations:

First, add a partition

The following code is added to a SALES table partition P3

ALTER TABLE SALES ADD PARTITION P3 VALUES LESS THAN(TO_DATE(‘2003-06-01′,’YYYY-MM-DD’));

Note: Add the partition beyond the limit should be higher than the last partition boundaries.

The following code P3 SALES table to add a partition subpartition P3SUB1

ALTER TABLE SALES MODIFY PARTITION P3 ADD SUBPARTITION P3SUB1 VALUES(‘COMPLETE’);

Second, delete partition

The following code removes the P3 partition table:

ALTER TABLE SALES DROP PARTITION P3;

Deleted P4SUB1 subdivision of the following code:

ALTER TABLE SALES DROP SUBPARTITION P4SUB1;

Note: If you delete the partition table is the only partition, then the partition will not be deleted in order to remove the partition, you must delete the table.

Third, the truncated partition

Truncate a partition refers to a partition to delete data, and does not delete the partition, it will not delete the data in other partitions. When the table even though only one partition, the partition may be truncated. Truncated partition with the following code:

ALTER TABLE SALES TRUNCATE PARTITION P2;

Cut child partition with the following code:

ALTER TABLE SALES TRUNCATE SUBPARTITION P2SUB2;

Fourth, merge partitions

The combined merged partition is partitioned into a neighboring partition, the partition will use the results of a high partition boundaries, it is noted that the partition can not be merged partition to a lower limit. The following code P1 P2 merged partitions:

ALTER TABLE SALES MERGE PARTITIONS P1,P2 INTO PARTITION P2;

Fifth, split partition

A partition partitioning split split two new partition, the partition is no longer the original split. HASH careful not to split the partition type.

ALTER TABLE SALES SBLIT PARTITION P2 AT(TO_DATE(‘2003-02-01′,’YYYY-MM-DD’)) INTO (PARTITION P21,PARTITION P22);

Six, engaging the partition (coalesca)

Binding data hash partition is the partition joined to the other partition, the partition when the hash data is relatively large, can increase the hash partitioning, and then joined, it is noteworthy that the engagement can only be used to hash the partition partition. Partition joined by the following code:

ALTER TABLE SALES COALESCA PARTITION;

Seven, rename table partitions

The following code will change the P2 P21

ALTER TABLE SALES RENAME PARTITION P21 TO P2;

Eight, the relevant inquiry

Cross-partition query

select sum( *) from

(select count(*) cn from t_table_SS PARTITION (P200709_1)

union all

select count(*) cn from t_table_SS PARTITION (P200709_2)

);

How many partitions on a lookup table

SELECT * FROM useR_TAB_PARTITIONS WHERE TABLE_NAME=’tableName’

Query index information

select object_name,object_type,tablespace_name,sum(value)

from v$segment_statistics

where statistic_name IN (‘physical reads’,’physical write’,’logical reads’)and object_type=’INDEX’

group by object_name,object_type,tablespace_name

order by 4 desc

- Displays information database of all the partition table:

select * from DBA_PART_TABLES

- All the partition table information accessible to the current user:

select * from ALL_PART_TABLES

- Displays information about the current user all the partition table:

select * from USER_PART_TABLES

- Display partition information table displays detailed partition information database of all the partition table:

select * from DBA_TAB_PARTITIONS

- Displays detailed information about all partitions partition table of the current user can access:

select * from ALL_TAB_PARTITIONS

- Displays detailed information about the current user partition all the partition table:

select * from USER_TAB_PARTITIONS

- Display partition information display sub-sub-partition information database partition table of all combinations:

select * from DBA_TAB_SUBPARTITIONS

- Displays information about all combinations of sub-partition partition table of the current user can access:

select * from ALL_TAB_SUBPARTITIONS

- display sub-partition information for the current user all combinations of partition table:

select * from USER_TAB_SUBPARTITIONS

- Display partition information database partitioning column column displays all the partition table:

select * from DBA_PART_KEY_COLUMNS

- partitioning column displays the partition table information for all of the current user can access:

select * from ALL_PART_KEY_COLUMNS

- partitioning column displays all information for the current user partition table:

select * from USER_PART_KEY_COLUMNS

- display sub-sub-partition database column shows all of the partition table partitioning column information:

select * from DBA_SUBPART_KEY_COLUMNS

- Displays the current user can access all of the sub-partition table partition column information:

select * from ALL_SUBPART_KEY_COLUMNS

- Displays the current sub-users all the partition table partitioning column information:

select * from USER_SUBPART_KEY_COLUMNS

- how to check out all of the oracle database partition tables

select * from user_tables a where a.partitioned=’YES’

- Delete a table of data is

truncate table table_name;

- Data Delete Partition is a partition table

alter table table_name truncate partition p5;

Guess you like

Origin www.cnblogs.com/yongestcat/p/11444640.html