Script to list all cmdb_ci tables with records

shane_davis
Tera Expert

We are working on a proof of concept in our SandBox instance and deleting all records from our "cmdb_ci_" tables.   As there are well over 800 tables, I need a script to list out the tables that are not empty so I will know which ones I need to delete the records from.

I ran the script below as a scheduled job and it deleted over 200k CIs in a few hours, but I don't know if that deleted all records from all cmdb_ci_ tables or if I have more cleanup to do.  

How would I create a script to loop through all the cmdb_ci_ tables and list out the ones with records?   Thank you for any assistance!

doit("cmdb_ci");

function doit(cmdb_ci) {

var gr = new GlideRecord(cmdb_ci);

gr.deleteMultiple();

}

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

That should do it. If you don't think so, check a sub table like cmdb_ci_hardware and see if there are records there. If you still have leftover data, I can help you build a list of tables. If you don't have to, then let's not go there.


View solution in original post

6 REPLIES 6

Mike - Great script!   Thank you.   Mine formatted in 2 very long rows, but I'm playing with that.   I appreciate the scripts.   See you at K17 hopefully!


Great!



Using


var table_array = mod_table_str.split(", ");



So with a space in the split you dont get a preceeding spave in your result array