Title: dbDelta() updates in 4.6
Author: Dominik Schilling
Published: July 13, 2016

---

 [  ](https://profiles.wordpress.org/ocean90/) [Dominik Schilling](https://profiles.wordpress.org/ocean90/)
12:23 pm _on_ July 13, 2016     
Tags: [4.6 ( 140 )](https://make.wordpress.org/core/tag/4-6/),
[database ( 7 )](https://make.wordpress.org/core/tag/database/), [dev-notes ( 648 )](https://make.wordpress.org/core/tag/dev-notes/)

# dbDelta() updates in 4.6

[dbDelta()](https://developer.wordpress.org/reference/functions/dbDelta/) is a function
which helps to modify the database based on specified SQL statements. In WordPress
4.6 this function has been updated to resolve some long standing bugs.

### Normalized index definitions

Previously, `dbDelta()` compared the raw SQL data for index definitions with the
output of `SHOW INDEX FROM`. This required a specific format so indices are not 
unnecessarily re-created. But this format wasn’t always ensured, until now. See 
[[37583]](https://core.trac.wordpress.org/changeset/37583):

 * `dbDelta()` now parses the raw index definition to extract the type, name and
   columns. With this data a normalized definition is build ([#20263](https://core.trac.wordpress.org/ticket/20263),
   [#34873](https://core.trac.wordpress.org/ticket/34873)).
 * CoreCore Core is the set of software required to run WordPress. The Core Development
   Team builds WordPress. standardize now on uppercase types ([#34871](https://core.trac.wordpress.org/ticket/34871))
   and on ‘KEY’. ‘INDEX’ is only a synonym for ‘KEY’.
 * ASC and DESC definitions are currently unused by MySQLMySQL MySQL is a relational
   database management system. A database is a structured collection of data where
   content, configuration and other options are stored. [https://www.mysql.com](https://www.mysql.com/),`
   dbDelta()` ignores them now too ([#34959](https://core.trac.wordpress.org/ticket/34959)).
 * Spaces in index definitions don’t create duplicate indices anymore ([#34869](https://core.trac.wordpress.org/ticket/34869)).

### Backtick all the things

Index names ([#20263](https://core.trac.wordpress.org/ticket/20263)), index column
names ([#20263](https://core.trac.wordpress.org/ticket/20263)), names in index change
queries ([#20263](https://core.trac.wordpress.org/ticket/20263)) and other queries(
[#31679](https://core.trac.wordpress.org/ticket/31679)) are now escaped with backticks
to improve compatibility with names which are reserved keywords.

### Support for SPATIAL keys

`dbDelta()` already supported spatial fields (by virtue of not checking field types),
so it’s nice to round that out with spatial key support, too. See [#36948](https://core.trac.wordpress.org/ticket/36948).

 

If you’re using `dbDelta()` in your pluginPlugin A plugin is a piece of software
containing a group of functions that can be added to a WordPress website. They can
extend functionality or add new features to your WordPress websites. WordPress plugins
are written in the PHP programming language and integrate seamlessly with WordPress.
These can be free in the WordPress.org Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
or can be cost-based plugin from a third-party. please test it with [WordPress 4.6](https://make.wordpress.org/core/handbook/testing/beta/)
and report any issues in the comments or on [Trac](https://core.trac.wordpress.org/component/Database).

There are still [a few issues](https://core.trac.wordpress.org/query?status=!closed&summary=~dbDelta)
with `dbDelta()`, can you help us to fix them? 🔨

[#4-6](https://make.wordpress.org/core/tag/4-6/), [#database](https://make.wordpress.org/core/tag/database/),
[#dev-notes](https://make.wordpress.org/core/tag/dev-notes/)

### Share this:

 * [  Threads ](https://make.wordpress.org/core/2016/07/13/dbdelta-updates-in-4-6/?share=threads)
 * [  Mastodon ](https://make.wordpress.org/core/2016/07/13/dbdelta-updates-in-4-6/?share=mastodon)
 * [  Bluesky ](https://make.wordpress.org/core/2016/07/13/dbdelta-updates-in-4-6/?share=bluesky)
 * [  X ](https://make.wordpress.org/core/2016/07/13/dbdelta-updates-in-4-6/?share=x)
 * [  Facebook ](https://make.wordpress.org/core/2016/07/13/dbdelta-updates-in-4-6/?share=facebook)
 * [  LinkedIn ](https://make.wordpress.org/core/2016/07/13/dbdelta-updates-in-4-6/?share=linkedin)

 1. ![](https://secure.gravatar.com/avatar/2705ec72762002e78c7aded24c0f5342a977a679a86abd8b1b3b2e09d5f6d715?
    s=32&d=mm&r=g)
 2.  [Mike Nelson](https://profiles.wordpress.org/mnelson4/)  4:36 pm _on_ July 13,
    2016
 3. right on! Ya we’ll test it out

Comments are closed.

# Post navigation

[← WP_Post_Type in 4.6](https://make.wordpress.org/core/2016/07/13/wp_post_type-in-4-6/)

[Weekly Dev Chat Agenda for July 13 — Twelve Weeks Later →](https://make.wordpress.org/core/2016/07/13/weekly-dev-chat-agenda-for-july-13-%f0%9f%8d%a6/)