Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

List all tables in my instance that contain data

SauravP67797804
Tera Expert

I would like to see a script which outputs all the tables on my platform which contains a data (list).

I am not able to get a script which pulls all tables on my instance that contain a data

3 REPLIES 3

Mark Manders
Giga Patron

Not sure what use it will have to see this information but you can try this:

var grTable = new GlideRecord('sys_db_object');
grTable.addQuery('super_class', ''); // Ensure you're only getting the base tables
grTable.query();
gs.print('Tables with data:');
while (grTable.next()) {
    var tableName = grTable.getValue('name');
    var grData = new GlideRecord(tableName);
    grData.setLimit(1); // Only need to check if there is at least one record
    if (grData.query() && grData.hasNext()) {
        gs.print(tableName);
    }
}

Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Mark Roethof
Tera Patron

Hi there,

 

Have a look at table:

sys_physical_table_stats

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Thanks Mark Roethof .. this was exactly what I was looking for..