Title: Multiple Database Tables for Plugin
Last modified: August 19, 2016

---

# Multiple Database Tables for Plugin

 *  Resolved [allstar](https://wordpress.org/support/users/allstar/)
 * (@allstar)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/multiple-database-tables-for-plugin/)
 * On activation I’m trying to have WP create 2 tables that my ‘plugin’ will need.
   I’ve tried using deltadb() and wpdb->query.
 * The SQL is properly formed (literally just a cut and paste out of a MySQL 4.0
   export).
 * I either get 1 table created or none respectively. Where am I going wrong?
 * `
    require_once(ABSPATH . "wp-admin/upgrade-functions.php"); // if database table
   doesn't already exist if ($installed_ver === false || $installed_ver != $plugin_db_version){
 *  $sql_one = "CREATE TABLE " . $this->db_table_one . " (
    <FIELDS> ) TYPE=InnoDB;";
   dbDelta($sql_one);
 *  $sql_two = "CREATE TABLE " . $this->db_table_two . " (
    <FIELDS> ) TYPE=InnoDB;";
   dbDelta($sql_two); }

Viewing 1 replies (of 1 total)

 *  Thread Starter [allstar](https://wordpress.org/support/users/allstar/)
 * (@allstar)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/multiple-database-tables-for-plugin/#post-680906)
 * The initial test was creating 1 Database table. Which stored the database version
   number.
 * The reason the plugin didn’t create the 3 tables was it was checking to see if
   the current database was a modern version. Which it was so it didn’t need to 
   add the ‘new’ tables.
 * Deleting the database version number from wp_options allowed all 3 tables to 
   be created on installation.

Viewing 1 replies (of 1 total)

The topic ‘Multiple Database Tables for Plugin’ is closed to new replies.

 * 1 reply
 * 1 participant
 * Last reply from: [allstar](https://wordpress.org/support/users/allstar/)
 * Last activity: [18 years, 4 months ago](https://wordpress.org/support/topic/multiple-database-tables-for-plugin/#post-680906)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
