title: mysql create table dynamically
body: <p>I am creating a database on mysql. First creating the principal tables which on average has 30 columns per table.
  And the standard of the log table is the pk of the referenced table plus each column * 2.
  Like this:</p>
  
  <p><strong>Referenced Table:</strong></p>
  
  <pre><code>Field   |   Type      |   Null   |   Key   |   Default   |   Extra
  --------+-------------+----------+---------+-------------+----------------
  TableID | int(11)     | No       | PRI     | Null        | auto_increment
  Col1    | varchar(50) | No       |         | Null        |
  </code></pre>
  
  <p><strong>Log Table:</strong></p>
  
  <pre><code>Field       |   Type      |   Null   |   Key   |   Default   |   Extra
  ------------+-------------+----------+---------+-------------+----------------
  LogTableID  | int(11)     | No       | PRI     | Null        | auto_increment
  TableID     | int(11)     | No       | MUL     | Null        |
  NewCol1     | varchar(50) | No       |         | Null        |
  UpdatedCol1 | varchar(50) | No       |         | Null        |
  </code></pre>
  
  <p>Now what I want is to create a procedure on which I pass the table name as a parameter and generates the creation of the table log query and executes it.</p>
  
  <p>What is the best way to do this?</p>