Database Essentials - Partitioning Tables and Indexes - Managing Partitions - Hash

Let us understand how to manage partitions using table users_hash_part which is partitioned using hash.

  • We would like to divide our data into 8 hash buckets.
  • While adding partitions for hash partitioned table, we need to specify modulus and remainder.
  • For each record inserted, a hash will be computed and divided by the value specified in modulus. Based on the remainder, the record will be inserted into the corresponding partition.

Key Concepts Explanation

Hash Partitioning

Hash partitioning divides data based on a hash function into multiple partitions. Each record’s value is hashed and divided by a specified modulus to determine the partition.

CREATE TABLE users_hash_part
PARTITION OF users_hash_part DEFAULT

Adding Partitions

In hash partitioning, each partition is created based on the modulus and remainder values.

CREATE TABLE users_hash_part_0_of_8
PARTITION OF users_hash_part FOR VALUES WITH (modulus 8, remainder 0)

Hands-On Tasks

  1. Create hash partitioned tables based on modulus and remainder values.
  2. Insert data into the hash partitioned table.
  3. Query data from each hash partition.


In this article, we learned how to manage partitions using hash partitioning and distribute data among different partitions based on a hash function. Practice managing partitions to improve your skills and understanding.

[Click here to watch the video that complements this article.](Video Link Placeholder with Text)

Watch the video tutorial here