Title: Plugin won&#039;t create table..
Last modified: August 24, 2016

---

# Plugin won't create table..

 *  [game_0ver](https://wordpress.org/support/users/game_0ver/)
 * (@game_0ver)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/plugin-wont-create-table/)
 * Hi, I am new to plugin development, I am having trouble getting my plugin to 
   automatically create my table.. can anyone see in my code why it won’t work? 
   If i run the query in phpMyAdmin (obviously replacing the variables with actual
   values) it seems to work… so i’m guessing it’s just the wpdb function doesn’t
   like it.
 * The plugin activates without errors.
 *     ```
       $table_name = $wpdb->prefix . "fb_events"; 
   
         $charset_collate = $wpdb->get_charset_collate();
   
         $sql = "CREATE TABLE $table_name (
         id int(9) NOT NULL AUTO_INCREMENT,
         name varchar(255) NOT NULL,
         slug varchar(255) NOT NULL,
         details text NOT NULL,
         location varchar(255) NOT NULL,
         start_date date NOT NULL,
         end_date date NULL,
         start_time varchar(255) NOT NULL,
         end_time varchar(255) NULL,
         image varchar(255) NOT NULL,
         comments int(1) DEFAULT '1',
         approved int(1) DEFAULT '0',
         user_id int(11) NOT NULL,
         created_at timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
         updated_at timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
         PRIMARY KEY  (id),
         UNIQUE KEY slug (slug)
       ) $charset_collate;";
   
         require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
         dbDelta($sql);
       ```
   

The topic ‘Plugin won't create table..’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [game_0ver](https://wordpress.org/support/users/game_0ver/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/plugin-wont-create-table/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
