Is it possible to create a horizontally partitioned table that is located on two separate sites in Oracle

oracleoracle-12c

I know that it is not possible to use @dblink syntax to assign tablespaces.

For example, the following would be illegal.

CREATE TABLE hr.admin_emp (
    empno      NUMBER(5) PRIMARY KEY
  )
  partition by range (empno)
  partition p1 values less than (100) tablespace tbspace1,
  partition p5 values less than (MAXVALUE) tablespace tbspace2@dbserver2;

Is there any alternative way to achieve a similar thing with Oracle12?

Best Answer

Starting with 12c, there is a new feature called Oracle Sharding.

Sharded Database Management

For example you can define the following shardspaces in Global Data Services with GDSCTL:

ADD SHARDSPACE –SHARDSPACE shspace1;
ADD SHARDSPACE –SHARDSPACE shspace2;

ADD SHARD –CONNECT shard1 –SHARDSPACE shspace1;
ADD SHARD –CONNECT shard2 –SHARDSPACE shspace1;
ADD SHARD –CONNECT shard3 –SHARDSPACE shspace1;

ADD SHARD –CONNECT shard4 –SHARDSPACE shspace2;
ADD SHARD –CONNECT shard5 –SHARDSPACE shspace2;
ADD SHARD –CONNECT shard6 –SHARDSPACE shspace2;
ADD SHARD –CONNECT shard7 –SHARDSPACE shspace2;

Where each shard is an independent, seperate database. Then create the tablespace sets as:

CREATE TABLESPACE SET tbs1 IN SHARDSPACE shspace1;
CREATE TABLESPACE SET tbs2 IN SHARDSPACE shspace2;

And create a partitioned table as:

CREATE SHARDED TABLE customers
( cust_id NUMBER NOT NULL
, name VARCHAR2(50)
, address VARCHAR2(250) 
, location_id VARCHAR2(20) 
, class VARCHAR2(3) 
, signup_date DATE 
, CONSTRAINT cust_pk PRIMARY KEY(class, cust_id) 
)
PARTITIONSET BY LIST (class) 
  PARTITION BY CONSISTENT HASH (cust_id)
  PARTITIONS AUTO
(PARTITIONSET gold VALUES (‘gld’) TABLESPACE SET tbs1,
 PARTITIONSET silver VALUES (‘slv’) TABLESPACE SET tbs2)
;