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
Tera 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);
    }
}

Mark Roethof
Tera Patron

Hi there,

 

Have a look at table:

sys_physical_table_stats

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