Title: plugin &#8211; creating extra tables
Last modified: August 20, 2016

---

# plugin – creating extra tables

 *  [Marty](https://wordpress.org/support/users/mrthrust/)
 * (@mrthrust)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-creating-extra-tables/)
 * hi guys/girls
 * Ive been banging my head against a wall with this one..
    its not something ive
   not done before. but this time i can get my plugin to create the second table..
 * the plugin on activation will create 2 new tables.
    clients & templates
 * /*TABLE CLIENTS */
 *     ```
       $table_clients  = $wpdb->prefix."pm_clients";
       if($wpdb->get_var("show tables like '".$table_clients."'") != $table_clients) {
       $sql1 = "CREATE TABLE ".$table_clients." (";
       $sql1.= "id INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,";
       $sql1.= "fname VARCHAR(100) NOT NULL, ";
       $sql1.= "lname VARCHAR(100) NOT NULL, ";
       $sql1.= "email VARCHAR(150) NOT NULL, ";
       $sql1.= "dob VARCHAR(20) NOT NULL, ";
       $sql1.= "currentage VARCHAR(10) NOT NULL,";
       $sql1.= "emailfreq VARCHAR(10) NOT NULL, ";
       $sql1.= "retage VARCHAR(10) NOT NULL, ";
       $sql1.= "pay VARCHAR(10) NOT NULL, ";
       $sql1.= "dateadded DATE NOT NULL, ";
       $sql1.= "contactdate DATE NOT NULL,";
       $sql1.= "lastemailed DATE NOT NULL";
       $sql1.= ") ENGINE = MyISAM;";
       require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
       dbDelta($sql1);
       }
       ```
   
 * this one is fine, it runs and creates the table..
 * but right under this one in my install function i have another table to create..
 *     ```
       $table_templates = $wpdb->prefix."pension_manager_templates";
       if($wpdb->get_var("show tables like '$table_templates'") != $table_templates) {	
   
       $sql2 = "CREATE TABLE $table_templates (";
       $sql2.= "id INT NOT NULL AUTO_INCREMENT PRIMARY  KEY,";
       $sql2.= "name VARCHAR ( 100 ) NOT NULL, ";
       $sql2.= "desc VARCHAR( 100 ) NOT NULL, ";
       $sql2.= "content TEXT NOT NULL, ";
       $sql2.= "status INT NOT NULL ";
       $sql2.= ") ENGINE = MyISAM;";
   
       require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
       dbDelta($sql2);
       }
       ```
   
 * which is never created…
 * can anyone see a reason why its not been made?
 * cheers

The topic ‘plugin – creating extra tables’ is closed to new replies.

## Tags

 * [wpdb](https://wordpress.org/support/topic-tag/wpdb/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Marty](https://wordpress.org/support/users/mrthrust/)
 * Last activity: [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-creating-extra-tables/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
