DBA Hub

📋Steps in this guide1/3

Read only Partition in Oracle 12.2 DBACLASS

Read only Partition in Oracle 12.2. Till now we can make a table read only, But what about setting few partitions of a table to read-only. We can do this in new

oracle clusteringintermediate
by OracleDba
16 views
1

Overview

Till now we can make a table read only, But what about setting few partitions of a table to read-only. Thanks to Oracle 12.2 Release, We can do this. This is usually helpful, If requirement is to make the historical data not editable. SYNTAX – ALTER TABLE MODIFY PARTITION READ ONLY;

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
SQL> col PARTITION_NAME for a32
SQL>  select partition_name,read_only from dba_tab_partitions where table_name='ORDER_TAB';

PARTITION_NAME                   READ
-------------------------------- ----
CREATED_2105_P10                 NO
CREATED_2105_P11                 NO
CREATED_2105_P12                 NO
CREATED_2105_P8                  NO
CREATED_2105_P9                  NO
CREATED_MX                       NO

6 rows selected.

SQL> alter table dbatest.ORDER_TAB modify partition CREATED_2105_P10 read only;

Table altered.

SQL>  select partition_name,read_only from dba_tab_partitions where table_name='ORDER_TAB';

PARTITION_NAME                   READ
-------------------------------- ----
CREATED_2105_P10                 YES
CREATED_2105_P11                 NO
CREATED_2105_P12                 NO
CREATED_2105_P8                  NO
CREATED_2105_P9                  NO
CREATED_MX                       NO

6 rows selected.
2

Section 2

If you tried to do any changes to the read only partition, it will throw below error. ORA-14466: Data in a read-only partition or subpartition cannot be modified. To make the read only partition to read write. I tried to modify multiple partitions with one command. Seems we need can make a partition read only each with one command. So if you wish to make 3 partitions read only, We need to run 3 ALTER TABLE MODIFY PARTITION command.

Code/Command (click line numbers to comment):

1
2
3
SQL> alter table dbatest.ORDER_TAB modify partition CREATED_2105_P10  read write;

Table altered.
3

Section 3

Code/Command (click line numbers to comment):

1
2
3
4
5
SQL> alter table dbatest.ORDER_TAB modify partition CREATED_2105_P10,CREATED_2105_P11,CREATED_2105_P12 read only;
alter table dbatest.ORDER_TAB modify partition CREATED_2105_P10,CREATED_2105_P11,CREATED_2105_P12 read only
*
ERROR at line 1:
ORA-14004: missing PARTITION keyword

Comments (0)

Please to add comments

No comments yet. Be the first to comment!