- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 05:09 PM
Hello,
We are on Helsinki and wanted to delete all the records (> 20k) from a table. How can I do that?
please advise.
Thanks,
Rajan Mehta
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 05:15 PM
Delete all records from a table
- Navigate to System Definition > Tables and Columns.
- Select the table for which to delete records.
Note: Some system tables do not allow this method of deleting records, for example, you cannot delete all user records [sys_user]. The list of tables does not include system tables that you cannot delete records from.
- Click Delete all records.
- In the confirmation dialog box, enter delete and click OK.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2017 09:26 PM
You might get a UI timeout as the Quota is for 5 minutes.
I think the best approach will be to perform this activity as follows:-
Create a script to perform this.
Run this as a Scheduled job so that it will not utilize the worker jobs and will run the background till this is completed.
May be you can split this into 5K records each within the script and run it as a loop.
Make sure that you clone from your PROD to SUB PROD and DRY RUN this on the SUB-PROD before running this on PROD. You also have to take into account about the cascade delete if these records are referenced somewhere. Only the data will be deleted and the stale references will still remain.It will good to test the impact on the SUB PROD.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2019 12:20 PM
I have 180,000 records to delete and the solution given only deletes about 1500 records at a time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2019 11:46 AM
Hello Sarah,
you can also use following script to delete all the records.
var rec = new GlideRecord ('Table_Name');
rec.addQuery('your_query');// Optional if specific records to delete
rec.query();
gs.info("# of Records:"+ rec.getRowCount());
while(rec.next()){
rec.deleteRecord();
}
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2020 10:34 AM
Hi Rajanmehata,
Above script took so long time to complete and ServiceNow instance also stuck.
We executed this script on 10K records at System Definition > Scripts - Background.
Please advise the best way to Cleanup CI.
Note# We have task to delete all CI's created by CredentiallessDiscovery.
Regards,
Vinil.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2020 03:15 PM
Hello Vinil,
Deleting large data from Background scripts it not a good idea if you know what you are doing.
Scripts running from Background scripts have the Record for Rollback checked by default. Data is deleted using semaphore threads and your instance will be accessible from a different browser window as a different session.
For large datasets, create scheduled jobs in chunks OOB hours so it will run in worker threads.
This KB will help you with queries on "Mass-Deletion and Excess Data Management Guide"
https://hi.service-now.com/kb_view.do?sysparm_article=KB0717791
Thanks,
Dipu Joy