Sharding in Oracle
Sharding is a feature in Oracle Database that allows a large database to be divided into smaller, independent databases called shards. Each shard can be stored on a different physical server, which can improve scalability and availability. Here is an example:
CREATE TABLE orders (
order_id NUMBER(10),
order_date DATE,
order_amount NUMBER(10,2),
customer_id NUMBER(10),
CONSTRAINT order_pk PRIMARY KEY (order_id)
)
PARTITION BY HASH (customer_id) PARTITIONS 4;
ALTER TABLE orders SHARD KEY (customer_id);
This creates a table named "orders" that is partitioned by the "customer_id" column using a hash-based partitioning strategy. The "SHARD KEY" option specifies that the table should be sharded based on the "customer_id" column.
No comments:
Post a Comment