create Verified current stable Not installed? Data Processing

Create / Create Table With Partition And Lifecycle

Create Table With Partition And Lifecycle

Creates a new partitioned table with a specified lifecycle policy.

$
Terminal
create table <table_name> (<col> <type>) partitioned by (<col> <type>) lifecycle <days>;

When To Use

In scenarios requiring data lifecycle management to automate data retention or deletion.

Pro Tip

Review partitioning strategies based on query performance; non-optimal partitioning can lead to degraded access patterns.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
create table <table_name> (<col> <type>) partitioned by (<col> <type>) lifecycle <days>;

Anatomy of Output

Understanding the result

Query OK, 0 rows affected (0.10 sec) Execution Summary

Indicates successful table creation.

CREATE TABLE `new_table_name` ( `column_name` data_type ) PARTITIONED BY ( `column_name` data_type ) LIFECYCLE number_of_days; SQL Command Output

Displays the executed SQL command for validation.

Troubleshooting

Common pitfalls

ERROR 1067 (42000): Invalid default value for 'column_name'

Solution: Specify a valid default value for the column.

ERROR 1050 (42S01): Table 'new_table_name' already exists

Solution: Use a different table name or drop the existing one.

ERROR 1480 (HY000): Lifecycle days must be a positive integer

Solution: Ensure lifecycle days specified are positive.

Command Breakdown

What each part is doing

create
Base Command
The executable that performs this operation. Here it runs Create before the shell applies any redirect operators.
<table_name>
table name
The value supplied for table name.
<col>
col
The value supplied for col.
<type>
type
The value supplied for type.
<days>
days
The value supplied for days.

Alternative Approaches

Comparable commands in other tools

Alternative data processing tools for the same job.