000033256 - How to determine real-time row counts of each table in the RSA Via Lifecycle & Governance AVUSER schema

Document created by RSA Customer Support Employee on Jun 16, 2016Last modified by RSA Customer Support Employee on Apr 21, 2017
Version 2Show Document
  • View in full screen mode

Article Content

Article Number000033256
Applies ToRSA Product Set: RSA Via Lifecycle & Governance (RSA Via L&G)
 
IssueThere may be times when you want to know the number of rows in each table of the RSA Via L&G AVUSER schema. There are a number of methods to do this:
  1. The Statistics Report (ASR) under SystemDiagnostics.
  2. Querying dba_tables as in:
$ sqlplus / avuser
SQL> SELECT table_name, num_rows FROM dba_tables WHERE owner='AVUSER' AND num_rows IS NOT NULL;

However, neither of these methods are real time. The row counts are based on the last time database statistics (db stats) ran. Furthermore, db stats does not count the rows in every single table. This article addresses a third method that allows you to create a SQL script file that calculates and reports the current row counts for every table in the AVUSER schema. You may also modify the file to include only those tables for which you want row counts.
Tasks
  1. Create a SQL command file that will count the number of rows in each table in the AVUSER schema. Please note you may modify these steps to include any schema of your choosing.
$ sqlplus / as sysdba
SQL> SPOOL <filename>.sql
SQL> SET linesize 300;
SQL> COLUMN ||TABLE_NAME|| FORMAT a200;
SQL> COLUMN COUNT(*) FORMAT a10;
SQL> SELECT 'SELECT '''||table_name||''',COUNT(*) FROM '||table_name||';' FROM dba_tables WHERE owner='AVUSER';
SQL> SPOOL OFF;

SQL> EXIT

 
  1. Modify the SQL command file created in step 1 so that it runs without error.  Using an editor of your choosing:
    1. Replace all occurrences of 'SELECT'''||TABLE_NAME||''',COUNT(*)FROM'||TABLE_NAME||';' with --, which is the SQL comment line command.  Below is a code snippet from such a file before making the change:
    2. Remove the top and bottom lines prefaced with 'SQL>'. Also remove 'no. of rows selected' from the bottom of the file.
'SELECT'''||TABLE_NAME||''',COUNT(*)FROM'||TABLE_NAME||';'                      
--------------------------------------------------------------------------------
SELECT 'T_AV_ROLE_TYPES',COUNT(*) FROM T_AV_ROLE_TYPES;                         
SELECT 'T_AV_VIOLATIONS',COUNT(*) FROM T_AV_VIOLATIONS;                         
SELECT 'T_AV_ROLEVER_VIOLATIONS',COUNT(*) FROM  T_AV_ROLEVER_VIOLATIONS;         
SELECT 'T_AV_USER_RULE_VIOLATIONS',COUNT(*) FROM  T_AV_USER_RULE_VIOLATIONS;     
SELECT 'T_AV_EXEMPTIONS',COUNT(*) FROM  T_AV_EXEMPTIONS;  
             
...

  1. After making the change:
--                      
--------------------------------------------------------------------------------
SELECT 'T_AV_ROLE_TYPES',COUNT(*) FROM T_AV_ROLE_TYPES;                         
SELECT 'T_AV_VIOLATIONS',COUNT(*) FROM T_AV_VIOLATIONS;                         
SELECT 'T_AV_ROLEVER_VIOLATIONS',COUNT(*) FROM T_AV_ROLEVER_VIOLATIONS;         
SELECT 'T_AV_USER_RULE_VIOLATIONS',COUNT(*) FROM T_AV_USER_RULE_VIOLATIONS;     
SELECT 'T_AV_EXEMPTIONS',COUNT(*) FROM T_AV_EXEMPTIONS;
               
...

  1. Save the file.
  2. Execute the file:
$ sqlplus avuser/secret
SQL> @<filename>

Attachments

    Outcomes