Does TiDB support automatic table partitioning?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb支持自动表分区吗

| username: TiDBer_QHSxuEa1

Can TiDB automatically partition tables? I have a log table and want to set it to automatically add table partitions by date.

| username: h5n1 | Original post link

Support Interval partitioning, automatic addition

| username: hey-hoho | Original post link

You can also use a shell script with cron to handle it :rofl:

| username: TiDBer_vfJBUcxl | Original post link

Partitioned Table | PingCAP Documentation Center

| username: redgame | Original post link

Sure.

| username: TiDBer_PyN8ad50 | Original post link

Supports partitioning and TTL, but it seems that in version 6.5, these are all experimental features.

CREATE TABLE monthly_report_status (
    report_id int NOT NULL,
    report_status varchar(20) NOT NULL,
    report_date date NOT NULL
)
PARTITION BY RANGE COLUMNS (report_date)
INTERVAL (1 MONTH) FIRST PARTITION LESS THAN ('2000-01-01') LAST PARTITION LESS THAN ('2025-01-01');

CREATE TABLE t1 (
    id int PRIMARY KEY,
    created_at TIMESTAMP
) TTL = `created_at` + INTERVAL 3 MONTH;
| username: cy6301567 | Original post link

Support, partitioning makes it convenient to quickly clean up historical useless data.

| username: cassblanca | Original post link

Learn about Interval.