Answers.Body: <p>It will depend on how the contributions were created and whether payments were associated with it.</p>
  
  <p>The best ERD I know of is this one doc.symbiotic.coop/dev/civicrm/latest/schema/index.html</p>
  
  <p>At a minimum you will probably need to check the civicrm_line_item table as well as civicrm_contribution.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-13T21:21:30.307Z
Answers.LastActivityDate: 2020-05-13T21:21:30.307Z
Answers.UserDisplayName: petednz - fuzion
Body: <p>I'm not 100% sure, if the next process is safe or not, so first of all, I ask... </p>
  
  <p>In my company's CiviCRM are more than 3900 Contributions, which should be deleted. These Contributions can be listed as result of a report in CiviReport, but not as result from the SearchBuilder because the query is too difficult for SearchBuilder (with 'NOT IN' clauses etc.). </p>
  
  <p>On the report's page, on the Developer tab I see the SQL query of the report, and I have access to the CiviCRM's database, so I can run this query. I can rewrite the SELECT query to a DELETE query. </p>
  
  <p>Is it safe - after backuping the database - run the DELETE query to delete all unneeded Contributions from the civicrm_contribution table, or it causes database inconsistency? </p>
  
  <p>Thank you!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-11T23:33:57.743Z
Comments.Text: HI Pál - will depend how the Contrib was added and if a payment or line items involved. if so there are many other table that could have linked data in which you would need to think through. you could look at this via the ERD https://doc.symbiotic.coop/dev/civicrm/latest/schema/index.html. Not sure what the gotcha is for you with SearchBuilder since i thought it did offer Not In but if not, have you considered the Include/Exclude custom search? We may have a query that clears out all the tables. If i can get hold of it quickly i will add as an answer
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-12T06:37:59.030Z
Comments.Text: Hi @petednz-fuzion - the clauses are the following: Is deleted (the contact): not, Contribution OR soft credit: Contribution only, Contribution status: completed, and these are custom fields: Recipient: empty, Account No: NOT IN (and here are five values). What I cam't make from SearchBuilder is the empty field. All these contributions was imported, and nothing was involved.
Comments.UserDisplayName: Pál Rudan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-12T06:44:31.643Z
Comments.Text: ... Sorry. All these contributions was imported, in the original import file are only the absolute minimum necessary fields are filled.
Comments.UserDisplayName: Pál Rudan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-12T09:08:37.233Z
Comments.Text: ok. then you may be okay to wield the SQL axe :-)
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-13T10:11:38.643Z
Comments.Text: I used :-) I have to delete rows from civicrm_contribution and civicrm_line_item tables. Thank you for the ERD, it's very useful.
Comments.UserDisplayName: Pál Rudan
Tags: <contributions><delete>
Title: Delete multiple Contributions
ThreadText: # Delete multiple Contributions
  
  (Asked by: username_0 on 2020-05-11)
  
  I'm not 100% sure, if the next process is safe or not, so first of all, I ask...
  
  In my company's CiviCRM are more than 3900 Contributions, which should be deleted. These Contributions can be listed as result of a report in CiviReport, but not as result from the SearchBuilder because the query is too difficult for SearchBuilder (with 'NOT IN' clauses etc.).
  
  On the report's page, on the Developer tab I see the SQL query of the report, and I have access to the CiviCRM's database, so I can run this query. I can rewrite the SELECT query to a DELETE query.
  
  Is it safe - after backuping the database - run the DELETE query to delete all unneeded Contributions from the civicrm\_contribution table, or it causes database inconsistency?
  
  Thank you!
  
  **Tags:** contributions, delete
  
  > **Comments:**
  > **username_1**: HI Pál - will depend how the Contrib was added and if a payment or line items involved. if so there are many other table that could have linked data in which you would need to think through. you could look at this via the ERD https://doc.symbiotic.coop/dev/civicrm/latest/schema/index.html. Not sure what the gotcha is for you with SearchBuilder since i thought it did offer Not In but if not, have you considered the Include/Exclude custom search? We may have a query that clears out all the tables. If i can get hold of it quickly i will add as an answer  
  > **username_0**: Hi @username_1 - the clauses are the following: Is deleted (the contact): not, Contribution OR soft credit: Contribution only, Contribution status: completed, and these are custom fields: Recipient: empty, Account No: NOT IN (and here are five values). What I cam't make from SearchBuilder is the empty field. All these contributions was imported, and nothing was involved.  
  > **username_0**: ... Sorry. All these contributions was imported, in the original import file are only the absolute minimum necessary fields are filled.  
  > **username_1**: ok. then you may be okay to wield the SQL axe :-)  
  > **username_0**: I used :-) I have to delete rows from civicrm_contribution and civicrm_line_item tables. Thank you for the ERD, it's very useful.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-05-13. Score: 2 | Accepted answer
  
  It will depend on how the contributions were created and whether payments were associated with it.
  
  The best ERD I know of is this one doc.symbiotic.coop/dev/civicrm/latest/schema/index.html
  
  At a minimum you will probably need to check the civicrm\_line\_item table as well as civicrm\_contribution.
  
  
  ---
  
  