database - Create partition if not exist on MySQL -


i have following table

id | p_key | col3 | col4 ------------------------  1 | pr1   | c1   | co1    2 | pr2   | c2   | co2  3 | pr3   | c3   | co3 

now have create partition on project key, like

if partition partpr1 not exist alter table create partition partpr1 

i want create partition p_key want check if exist or not before inserting record, if exist insert in partition else first create partition insert.

not posting code. because i'm able create simple partition, not getting logic implement desired scenario.

according mysql manual

add partition , drop partition not support if [not] exists.

also syntax incorrect anyway,

alter table t1 add partition (partition p3 values less (2002));

but page in manual may useful show number of ways can query mysql , @ results see if partition name exists.

via either show commands or querying information_schema.partitions table directly.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -