Title: WordPress database error: [Multiple primary key defined]
Last modified: August 20, 2016

---

# WordPress database error: [Multiple primary key defined]

 *  Resolved [qaws](https://wordpress.org/support/users/qaws/)
 * (@qaws)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined/)
 * If I have WP_DEBUG set to true I get the following message:
 * WordPress database error: [Multiple primary key defined]
    ALTER TABLE wp_simple_post_templates
   ADD PRIMARY KEY (`id`)
 * [http://wordpress.org/extend/plugins/simple-post-template/](http://wordpress.org/extend/plugins/simple-post-template/)

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Thread Starter [qaws](https://wordpress.org/support/users/qaws/)
 * (@qaws)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined/#post-3298229)
 * This is in the debug.log:
 * [21-Dec-2012 14:17:01] WordPress database error Multiple primary key defined 
   for query ALTER TABLE wp_simple_post_templates ADD PRIMARY KEY (‘id’) made by
   require(‘wp-blog-header.php’), require_once(‘wp-load.php’), require_once(‘wp-
   config.php’), require_once(‘wp-settings.php’), include_once(‘/plugins/simple-
   post-template/simple-post-template.php’), SimplePostTemplate->__construct, SimplePostTemplate-
   >activate, dbDelta
 * (note I changed the backticks of the primary key to apostrophe’s in this post
   so they appear)
 *  [obsessedwithfilm](https://wordpress.org/support/users/obsessedwithfilm/)
 * (@obsessedwithfilm)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined/#post-3298272)
 * Same issue. Had to disable the plugin as it was adding hundreds of lines to an
   error log every minute.
 * WordPress 3.5
 *  [tpecop](https://wordpress.org/support/users/tpecop/)
 * (@tpecop)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined/#post-3298298)
 * Same here, updated this plugin and got tons of errors.
 *  [AdamConway](https://wordpress.org/support/users/adamconway/)
 * (@adamconway)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined/#post-3298300)
 * Same here. In my case it’s a table I define in my own plugin, not a third party
   wordpress plugin, but the code (run on plugin_activate) worked under the previous
   WP version:
 *     ```
       $sql = "CREATE TABLE $cpr_tablesname (
         id varchar(100) NOT NULL,
         PRIMARY KEY (id)
       );";
       require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
       dbDelta($sql);
       ```
   
 * (example simplified by removing other fields)
 * However, on double checking the [docs for dbdelta](http://codex.wordpress.org/Creating_Tables_with_Plugins)
   I found the follwoing:
 * > You must have two spaces between the words PRIMARY KEY and the definition of
   > your primary key.
 * This fixed it for me. Suggest you check the source of the plugin in question 
   and if that is the problem contact the author.
 *  Plugin Author [Clifton Griffin](https://wordpress.org/support/users/clifgriffin/)
 * (@clifgriffin)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined/#post-3298303)
 * Hey guys!
 * Hadn’t heard about this error until yesterday when a kind soul e-mailed me to
   ask me about it.
 * I just uploaded version 2.0.5 that implements the fix above from AdamConway, 
   as well as several other recommendations from the dbDelta article.
 * I did a brief test and did not see any errors in my log.
 * Regards,
    Clif
 *  [one3rdnerd](https://wordpress.org/support/users/one3rdnerd/)
 * (@one3rdnerd)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined/#post-3298307)
 * I am getting this error now.
 * pache2/pixelloop-error.log
    [Mon Jul 08 14:45:16 2013] [error] [client 90.206.209.32]
   WordPress database error Multiple primary key defined for query ALTER TABLE c2sjh_wpcreviews
   ADD PRIMARY KEY (id) made by require_once(‘wp-admin/admin.php’), require_once(‘
   wp-load.php’), require_once(‘wp-config.php’), require_once(‘wp-settings.php’),
   do_action(‘init’), call_user_func_array, WPCustomerReviews->init, WPCustomerReviews-
   >check_migrate, WPCustomerReviewsAdmin->createUpdateReviewTable, dbDelta, referer:
   [http://pixelloop.org/wp-admin/update.php?action=upgrade-plugin&plugin=wp-customer-reviews%2Fwp-customer-reviews.php&_wpnonce=df8baca746](http://pixelloop.org/wp-admin/update.php?action=upgrade-plugin&plugin=wp-customer-reviews%2Fwp-customer-reviews.php&_wpnonce=df8baca746)
 * Is this something that can be patched again? is this the same or different to
   the previous error?
 *  Plugin Author [Clifton Griffin](https://wordpress.org/support/users/clifgriffin/)
 * (@clifgriffin)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined/#post-3298308)
 * It looks like your error is coming from WP Customer Reviews, not my plugin.
 *  [one3rdnerd](https://wordpress.org/support/users/one3rdnerd/)
 * (@one3rdnerd)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined/#post-3298309)
 * ooops my bad, I came across this thread when googling my error but it must have
   been a different part.
 * Thanks
 *  [one3rdnerd](https://wordpress.org/support/users/one3rdnerd/)
 * (@one3rdnerd)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined/#post-3298310)
 * ooops my bad, I came across this thread when googling my error but it must have
   been a different part.
 * Thanks

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘WordPress database error: [Multiple primary key defined]’ is closed to
new replies.

 * ![](https://ps.w.org/simple-post-template/assets/icon.svg?rev=2425232)
 * [Simple Content Templates for Blog Posts & Pages](https://wordpress.org/plugins/simple-post-template/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simple-post-template/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simple-post-template/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-post-template/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-post-template/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-post-template/reviews/)

 * 9 replies
 * 6 participants
 * Last reply from: [one3rdnerd](https://wordpress.org/support/users/one3rdnerd/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined/#post-3298310)
 * Status: resolved