Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Rajeshwaran.

Asked: March 21, 2017 - 5:48 pm UTC

Last updated: October 02, 2018 - 7:00 am UTC

Version: 12.2.0.1

Viewed 1000+ times

You Asked

Team,

Started reading about Read Only partitions in 12.2

http://docs.oracle.com/database/122/VLDBG/partition-create-tables-indexes.htm#VLDBG-GUID-9D7149B6-A2FF-47CA-8F00-47CBFD33F82B

<quote>
A higher level setting of the read-only clause is applied to partitions and subpartitions unless the read-only clause has been explicitly set for a partition or subpartition.
</quote>

demo@ORA12C> create table t1
  2  partition by list(x)
  3  subpartition by list(y)
  4  subpartition template(
  5     subpartition sp1 values (0) READ ONLY ,
  6     subpartition sp2 values (1) )
  7  (  partition p1 values (0) READ ONLY ,
  8     partition p2 values (1) READ WRITE ,
  9     partition p3 values (2) )
 10  as
 11  select mod(rownum,3) as x, mod(rownum,2) as y ,
 12             object_name, created
 13  from all_objects
 14  where rownum <= 100;

Table created.

demo@ORA12C> column table_name format a10
demo@ORA12C> column partition_name format a10
demo@ORA12C> column subpartition_name format a10
demo@ORA12C> select table_name,partition_name,subpartition_name,read_only
  2  from user_tab_subpartitions
  3  where table_name ='T1'
  4  order by partition_name,subpartition_name;

TABLE_NAME PARTITION_ SUBPARTITI REA
---------- ---------- ---------- ---
T1         P1         P1_SP1     YES
T1         P1         P1_SP2     YES
T1         P2         P2_SP1     NO  <======( This confuses me )
T1         P2         P2_SP2     NO
T1         P3         P3_SP1     YES
T1         P3         P3_SP2     NO

6 rows selected.

demo@ORA12C>


Subpartition SP1 is set to READ ONLY explicitly at the subpartition template.
Partition P2 is set to READ WRITE explicitly at partition level.

Since the subpartition SP1 is set to READ ONLY explicitly, across all the partitions this Sub-partition should be read only, but how ever that is not the case here( please see the partition P2 above).

without sub-partition template, things went like this.

demo@ORA12C> drop table t1 purge;

Table dropped.

demo@ORA12C> create table t1
  2  partition by list(x)
  3  subpartition by list(y)
  4  (  partition p1 values (0) READ ONLY
  5             (       subpartition p1_sp1 values (0) READ ONLY ,
  6                     subpartition p1_sp2 values (1) ) ,
  7      partition p2 values (1) READ WRITE
  8             (   subpartition p2_sp1 values (0) READ ONLY ,
  9                     subpartition p2_sp2 values (1) ) ,
 10     partition p3 values (2)
 11             (       subpartition p3_sp1 values (0) READ ONLY ,
 12                     subpartition p3_sp2 values (1) )
 13     )
 14  as
 15  select mod(rownum,3) as x, mod(rownum,2) as y ,
 16             object_name, created
 17  from all_objects
 18  where rownum <= 100;

Table created.

demo@ORA12C> column table_name format a10
demo@ORA12C> column partition_name format a10
demo@ORA12C> column subpartition_name format a10
demo@ORA12C> select table_name,partition_name,subpartition_name,read_only
  2  from user_tab_subpartitions
  3  where table_name ='T1'
  4  order by partition_name,subpartition_name;

TABLE_NAME PARTITION_ SUBPARTITI REA
---------- ---------- ---------- ---
T1         P1         P1_SP1     YES
T1         P1         P1_SP2     YES
T1         P2         P2_SP1     YES <====( this looks perfect to me)
T1         P2         P2_SP2     NO
T1         P3         P3_SP1     YES
T1         P3         P3_SP2     NO

6 rows selected.

demo@ORA12C>


are we hitting any bug here? please correct me on this understanding about READ ONLY partition in the context of Composite partitioned tables.

and Connor said...

I think that's a bug.

I'll talk to the partitioning team and get their confirmation, and log it if that's the case.

Rating

  (6 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Thanks

Rajeshwaran, March 29, 2017 - 6:11 am UTC

Team - thanks for the update.

When contacted "Hermann Baer - hermann.baer@oracle.com" the author of this blog post https://blogs.oracle.com/datawarehousing/entry/the_latest_in_oracle_partitioning
Here is what he said.
....
Yes, I am/we are aware that there is an inconsistency in behavior for attributes defined in the subpartition template, which is unfortunately not fixed yet in any release (bug 24759766). The best practices here at the moment are to specify explicitly what attribute you want to set ..
....

Read only table in backup

Ramki, May 14, 2018 - 5:53 am UTC

hi,
in our application, we have to maintain day level partition for 200 -300 days. DB was growing daily, and hence backup time & backup disk also. is there any way I can mark older partitions to read-only and avoiding backup of these read-only partitions. similar to read-only Tablespace. if such options is there then it will be a very big advantage for these kinds of applications. Let me know your suggestions thanks.
Regards
Ramki
Connor McDonald
May 18, 2018 - 2:10 am UTC

Not to my knowledge, but one of the cool things with read only partitions is that you can still do maintenance operations on them.

So you could move them a separate tablespace, mark that tablespace read only and get the backup optimization that way.

Or just look at using block change tracking perhaps.

Read only table in backup

Ramki, May 18, 2018 - 5:46 am UTC

Thanks for your reply. I am thinking of creating a new tablespace for every week say tabs_2018wk21, tabs_2018wk21 ...so on and daily partitions of that week are created in the respective week. Once a week is over say on Monday, I will make previous week TBS as read-only. this will avoid table movement & while dropping older partition after 300 days I can drop oldest tables & respective TBS of that week. Do you see any issue with this trick?
Connor McDonald
May 21, 2018 - 11:34 am UTC

That seems reasonable. Even if you only had monthly tablespaces you could do:

- make tablespace read-write
- move todays, or this weeks partitions into it
- make it read-only
- back it up


Read only TBS in restore

Ramki, September 26, 2018 - 2:14 pm UTC

HI,

We want to implement read-only TB for history data say one TBS per month. Now while restoring DB we want to skip the RO TBS and restore it later.
Can we restore RO TBS by keeping DB online, or any other faster way of restoring RO TBS with less or NO downtime for DB.
Regards
Ramki
Connor McDonald
September 27, 2018 - 2:25 am UTC

Yes, with RMAN you can issue commands such as:

restore database skip tablespace MY_TABLESPACE;
recover database skip tablespace MY_TABLESPACE;

Ramki, September 27, 2018 - 6:00 am UTC

Hi,
Thanks for your reply, My doubt is

restore RO TBS as the 2nd step with no downtime for DB.

1. restore RW TBS quickly
2. make DB up & online
3. restore RO TBS when DB is online with no downtime.

is above scenario possible
Regards
Ramki


Connor McDonald
October 02, 2018 - 7:00 am UTC

Yes that it possible, in the same way that you can transport a read only tablespace from one database to another.

HASH Partition on External Tables

Rajeshwaran, Jeyabal, September 29, 2018 - 10:43 am UTC

Team,

is that Hash partition is not supported on External tables?

looked into the documentation, it says only References,auto list, interval partitions are not supported.

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/admin/managing-tables.html#GUID-43901AC6-BA21-4B1E-977C-41E031472E8D

demo@ORA12C> CREATE TABLE t_ext
  2  (
  3    X NUMBER,
  4    Y VARCHAR2(300)
  5  )
  6  ORGANIZATION external
  7  (
  8    TYPE oracle_loader
  9    DEFAULT DIRECTORY tmp
 10    ACCESS PARAMETERS
 11    (
 12      RECORDS DELIMITED BY NEWLINE CHARACTERSET WE8MSWIN1252
 13      REJECT ROWS WITH ALL NULL FIELDS
 14      (
 15        X RECNUM,
 16        Y (1:300) CHAR(300)
 17      )
 18    )
 19  )REJECT LIMIT UNLIMITED
 20  partition by hash(x)
 21  ( partition p1 ,
 22    partition p2 );
partition by hash(x)
                 *
ERROR at line 20:
ORA-14151: invalid table partitioning method


kindly advice.
Connor McDonald
October 02, 2018 - 6:59 am UTC

I suspect that will be a documentation bug.

I can't think of a reason why we'd want to hash partition an external table

More to Explore

VLDB

If you are new to partitioning, check out Connor McDonald's introduction series here.

VLDB

Documentation set on VLDB and Partitioning.