Everything You Need to Know About Gravity Forms Database Structure
Everything you need to know about the database structure of Gravity Forms, a critical plugin for dynamic, interactive websites powered by WordPress today. Understand the database structure, and how the plugin handles data in the backend.
- Gravity Forms SQL Tables
- Where are these SQL Tables stored?
- Sample SQL Queries
- Forcing Gravity Forms Database Updates
- Integrate Gravity Forms with a Database
- Final Thoughts
Most of the time, you never need to think about where Gravity Forms keeps its data. But when you’re debugging a broken update, building a custom report, or answering a GDPR request, knowing the tables matters.
This guide covers each Gravity Forms table, explains where your entry data actually lives, and includes ready-to-run SQL queries for the things people most often need.
Gravity Forms SQL Tables
The table names below assume your site uses the default wp_ table prefix. If yours uses a different prefix, substitute it. Every Gravity Forms table also carries its own gf_ prefix.
The tables fall into three groups: forms, entries, and add-ons. Anything created through the Gravity Forms REST API ends up in these same tables.
Form Data
The basic information about a form is stored in wp_gf_form. That includes the form title, creation date, and whether the form is active or trashed. The full form configuration, including fields, labels, confirmations, and notifications, is stored as JSON in wp_gf_form_meta. View counts are stored in wp_gf_form_view. Each row in the meta and view tables links back to a single form in wp_gf_form.
Entries Data
Each submission creates one row in wp_gf_entry. That row holds the entry’s properties, not its field values: the form it belongs to, created and updated dates, the user who submitted it, IP, source URL, status (active, spam, or trash), and payment details if applicable. See the Entry Object for the full list. Did you know you can edit entries on the front end too?
The field values live in wp_gf_entry_meta. Each value is its own row, keyed by entry_id, with the field ID in meta_key and the submitted value in meta_value. Multi-input fields store one row per input using a decimal ID. For example, a Name field with ID 1 stores first name as 1.3 and last name as 1.6. Add-ons also store their own entry data here, under non-numeric keys.
Field labels are not stored with entries. They live in the form’s JSON configuration (display_meta in wp_gf_form_meta), so a raw query returns field IDs, not labels.
Entry notes go in wp_gf_entry_notes. Partial submissions from Save and Continue go in wp_gf_draft_submissions until the user completes the form.
Worth knowing…
Every entry has a status property, like active, spam, or trash. If you’d rather not delete old entries, our free Entry Archive plugin adds an archived status, so you can clear them from view without touching the underlying data.
Add-On Data
Gravity Forms creates three tables to support its add-ons. wp_gf_addon_feed stores each add-on feed’s configuration, such as a Stripe or Mailchimp feed, and which form it belongs to.
If an add-on processes payments, the wp_gf_addon_payment_transaction and wp_gf_addon_payment_callback tables store the transaction and callback details, respectively.
Where are these SQL Tables stored?
The tables live in the same MySQL or MariaDB database as the rest of your WordPress site. To browse them, use phpMyAdmin (most hosts include it) or the MySQL command line. If you have WP-CLI, wp db query runs SQL directly against your site’s database.
Sample SQL Queries
These queries assume the default wp_ prefix and a form with ID 1. Change both to match your site, along with any field IDs. Treat them as read-only. To create or update entries, use the GFAPI instead of writing to these tables directly.
All entry values for a form
SELECT e.id AS entry_id, e.date_created, m.meta_key AS field_id, m.meta_value
FROM wp_gf_entry e
JOIN wp_gf_entry_meta m ON m.entry_id = e.id
WHERE e.form_id = 1
AND e.status = 'active'
AND m.meta_key REGEXP '^[0-9.]+$' -- field values only, skips add-on meta
ORDER BY e.id, m.meta_key + 0;
One row per entry, with specific fields as columns
SELECT e.id AS entry_id, e.date_created,
MAX(CASE WHEN m.meta_key = '1.3' THEN m.meta_value END) AS first_name,
MAX(CASE WHEN m.meta_key = '1.6' THEN m.meta_value END) AS last_name,
MAX(CASE WHEN m.meta_key = '2' THEN m.meta_value END) AS email
FROM wp_gf_entry e
JOIN wp_gf_entry_meta m ON m.entry_id = e.id
WHERE e.form_id = 1 AND e.status = 'active'
GROUP BY e.id, e.date_created
ORDER BY e.date_created DESC;
Entries where a field matches a value
SELECT e.id, e.date_created
FROM wp_gf_entry e
JOIN wp_gf_entry_meta m ON m.entry_id = e.id
WHERE e.form_id = 1
AND m.meta_key = '2'
AND m.meta_value LIKE '%@example.com';
Entry counts by form and status
SELECT f.id, f.title, e.status, COUNT(e.id) AS entries
FROM wp_gf_form f
LEFT JOIN wp_gf_entry e ON e.form_id = f.id
GROUP BY f.id, f.title, e.status
ORDER BY f.id;
Field IDs and labels for a form
This one requires MySQL 8.0+ or MariaDB 10.6+.
SELECT jt.field_id, jt.label, jt.type
FROM wp_gf_form_meta fm,
JSON_TABLE(fm.display_meta, '$.fields[*]' COLUMNS (
field_id INT PATH '$.id',
label VARCHAR(255) PATH '$.label',
type VARCHAR(50) PATH '$.type'
)) jt
WHERE fm.form_id = 1;
A few fields need extra handling. Checkbox fields store one row per checked choice. List fields store serialized arrays. Multi-file upload fields store a JSON array of URLs.
Forcing Gravity Forms Database Updates
With the release of Gravity Forms 2.3, several tables were deprecated and should not be used. Future updates may also lead to changes in the database structure. Therefore, when you update the Gravity Forms plugin, you may encounter an error in the plugin due to the failure in the database modification.
Gravity Forms has a feature to manually run the database modification script after you have updated the plugin. In the WordPress admin dashboard, select the System Status option under the Forms menu. In the Database section, choose the option to “Re-run database upgrade” to port your database tables from the old structure to create new tables. As this process involves changing tables in your database directly, it is a good idea to back up your database in case the process fails and corrupts the plugin.
Integrate Gravity Forms with a Database
If you want to use database data in your forms, rather than just look at it, GP Populate Anything can populate fields and choices directly from any table in your WordPress database. It can also pull from other Gravity Forms entries. That covers things like a dropdown built from a custom table, or a form prefilled from a previous submission, with no SQL required.
To get entry data out of WordPress for reporting, Gravity Forms Google Sheets syncs entries to a spreadsheet automatically. From there, it connects to Looker Studio, BigQuery, and other tools.
Final Thoughts
Gravity Forms keeps form configuration in wp_gf_form and wp_gf_form_meta, entry properties in wp_gf_entry, and the submitted values themselves in wp_gf_entry_meta. Once you know that split, the queries above cover most reporting and debugging needs. When you want that data working inside your forms instead, Populate Anything handles it without SQL.
You need Gravity Perks to get the full power of Gravity Forms! Buy Gravity Perks today to all of our galactic Gravity Forms plugins!
hi does this work with nest gravity form ?
Hi CV,
Nested Form entries are stored just like normal Gravity Forms entries. So yes, it also applies to Nested Forms.
Best,
Ryan, would be great if you threw in some sample MySql queries – e.g. show me all the entries (field names and entry values) for a specific form, etc.
Hello There, Thank you so much for the recommendation. We have noted this and may add this as we update our documentation. Thank you so much again!
Thanks I am looking for the database record where the chosen currency is stored it must be in the database and not on php level I think that because I have a multi/networked site with for each subsites own currencies
Hey Jack, Just confirmed with the development team and GFCommon::get_currency() will provide them with the current currency that Gravity Forms is using.That’s a PHP function/method straight from Gravity Forms. Something to note is it does pull the rg_gforms_currency option in the wp_options table on the database if it’s set.
It is a nice description of the database usages but I mis the place where the gravity options are stored in the database probably in the wp_options table but I can not find them. I need that because with the default currency must be filled in and we have a lot of subsites.
Gravity forms has been update and somtimes the currency is not find but form execution crashes when currency is empty. even when there is no currency field on the form.
Hello Jack, you can find the documentation on the Gravity Forms Currency hooks here. If your forms are having issues with selecting certain currencies, I would reach out to Gravity Forms Support.