Create partition if not exist on MySQL
<p>I have the following table</p>

<pre><code>id | p_key | col3 | col4
------------------------
 1 | pr1   | c1   | co1  
 2 | pr2   | c2   | co2
 3 | pr3   | c3   | co3
</code></pre>

<p>Now I have to create partition on project key, something like</p>

<pre><code>If partition partpr1 not exist
alter table create partition partpr1
</code></pre>

<p>I want to create partition with <code>p_key</code> but want to check if it exist or not before inserting record, if it exist it will insert in that partition else it will first create partition then insert.</p>

<p>Not posting any code. because I'm able to create simple partition, but could not getting any logic to implement desired scenario.</p>