CodeBlanks Logo Icon CodeBlanks

What is partitioning?

Split a large table into pieces.

What is a partition?

A partition splits a large table into pieces. Each piece is stored separately.

CREATE TABLE sales (id INT, sale_date DATE, amount DECIMAL)
PARTITION BY RANGE (sale_date);

Partition by date.

The table sales is created.

What is a partition? — details

Partitioning improves query performance. Only relevant pieces are scanned.

For example, if you partition sales by year, a 2026 report reads only the 2026 partition; older years are never scanned.

Practice What is a partition?

Partition the sales table with PARTITION BY RANGE (sale_date).

Starter code

query.sql
-- partition table
CREATE TABLE sales

Sample solution

query.sql
CREATE TABLE sales (id INT, sale_date DATE, amount DECIMAL)
PARTITION BY RANGE (sale_date);

Expected output

Tablo oluşturuldu

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What does partitioning split?

  • The view
  • The index
  • The table Correct answer
  • The trigger

Explanation: Partitioning splits a table.

2 Add PARTITION BY

Question
CREATE TABLE sales (id INT, sale_date DATE, amount DECIMAL)
____ RANGE (sale_date);
Answer
CREATE TABLE sales (id INT, sale_date DATE, amount DECIMAL)
PARTITION BY RANGE (sale_date);

Explanation: PARTITION BY is the right answer.

3 What is partitioning: match the terms

Term Meaning
partition partition
RANGE range
LIST list
HASH hash

All lessons in Advanced