Warning message

The service having id "digg_smart_button" is missing, reactivate its module or save again the list of services.

Delete all webform results in Drupal

I have faced a problem when I have trying to delete a huge number of records (more than 10,000) that are submitted in the webform at once in Drupal 7. Every time I tried to clear data; I was redirected to a white screen and the deletion was never executed. Increasing PHP memory limit and the max_execution_time didn’t help.

In order to solve this problem, I had to directly deal with the database tables. The tables in question are: 

  1. webform_submissions
  2. webform_submitted_data

 

First: Please take a backup of your database. You don't want to end up having your Drupal database tables messed up.

"webform_submissions": On this table we have to focus on (nid) column, in this column we will have the ids of all the webforms on our website, so we have first to search for all rows with the specific id of the node id (webform id), and then if you are sure that these are the record that you want to delete, you can write the following sql query.

Deleting Webform Results
 
DELETE FROM webform_submissions WHERE nid=NODidOFtheWEBFORM 
-- replace NODidOFtheWEBFORM with the node id of the webform that you are going to delete its records.
 
 
 
Another sql query has to be run against "webform_submitted_data" table in order to actually delete the webform results.
DELETE FROM webform_submitted_data WHERE nid=NODidOFtheWEBFORM 
-- replace NODidOFtheWEBFORM with the node id of the webform that you are going to delete its records.
After doing this go back to your webform and check the results and you will find nothing, that's all and you are done.