Home > Mobile >  partitioning in MySQL : insert into partition
partitioning in MySQL : insert into partition

Time:06-05

I come from an Apache Hive background.

In that language, you would say the below to insert into date 20220601:

insert into table db.tablename partition(date=20220601)

In MySQL; I can't get such an insert statement to work. I have been Googling & it seems it just sorts itself out?

So if I did

insert into db.tablename
select * from db.othertable

Would it automatically partition the ingested data?

I feel like I am missing something here!

CodePudding user response:

If the table is partitioned, the values you insert determine which partition the row goes into. Partitioning a table requires you define the mapping, so it's always deterministic which partition a row goes into.

Therefore you don't need to tell INSERT which partition to insert the row into. It's determined automatically by the values you insert in the row.

Partitioning in MySQL is not required for a table. By default, a table is not partitioned. This is normal and sufficient in almost all cases.

Perhaps partitioning in Apache Hive is necessary and does something different from the feature called partitioning in MySQL? I don't know Apache Hive, so I can't answer that.

I suggest you read the MySQL manual chapter about partitioning if you want to learn more about it: https://dev.mysql.com/doc/refman/8.0/en/partitioning.html

  • Related