Partitioning of tables in Oracle12c

When switching users, it is best to use su - username to enter

Create a new user name and password:
SQL>create user abc identified by abc;
switch users:
SQL>conn abc/abc;
switch the highest user:
SQL>conn / as sysdba;
for User addition authority:
SQL>grant dba to abc;

sqlplus / as sysdba The sysdba user has entered the database
Related commands:
desc table name lists each field of the table

Query the table under the current user:
SQL>select tname from tab;

partition of the table :
  For example: Create table: SQL> CREATE TABLE test2(userId number(8), username varchar2(40), tep number (20)) PARTITION BY RANGE (userId)(PARTITION p1 VALUES LESS THAN (10000), PARTITION p2 VALUES LESS THAN (20000), PARTITION p3 VALUES LESS THAN (30000) );
  
     Add two areas to the table: SQL> ALTER TABLE test2 ADD PARTITION p4 VALUES LESS THAN (35000), PARTITION p5 VALUES LESS THAN (40000);

To undo multiple partitions:
SQL> ALTER TABLE test2 DROP PARTITIONS p4,p5; To
merge multiple partitions:
SQL> ALTER TABLE test2 TRUNCATE PARTITONS p4,p5;

To keep indexes updated, use the UPDATE INDEXES or UPDATE GLOBAL INDEXES statement
SQL> ALTER TABLE test2 DROP PARTITIONS p4,p5 UPDATE GLOBAL INDEXES;
SQL> ALTER TABLE test2 TRUNCATE PARTITIONS p4,p5 UPDATE GLOBAL INDEXES;

Split a single partition into multiple new partitions:
SQL> CREATE TABLE test2 (userId number(8), username varchar2(40) , tep number (20)) PARTITION BY RANGE (sal) (PARTITION p1 VALUES LESS THAN (10000), PARTITION p2 VALUES LESS THAN (20000), PARTITION p_max (MAXVALUE) );
SQL> ALTER TABLE test2 SPLIT PARTITION p_max INTO (PARTITION p3 VALUES LESS THAN (25000), PARTITION p4 VALUES LESS THAN (30000), PARTITION p_max);

Merge multiple partitions into one partition:
SQL> ALTER TABLE test2 MERGE PARTITIONS p3,p4,p5 INTO PARTITION p_merge;

If the partition range forms a sequence, you can use the following example:
SQL> ALTER TABLE test2 MERGE PARTITIONS p3 TO p5 INTO PARTITION p_merge;

View all partition table partition details of the current user Information:
SQL> select table_name, partition_name from user_tab_partitions;

display information about all partition tables of the current user
SQL> select table_name from user_part_tables;

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326698619&siteId=291194637