Get column name length distribution in Oracle database

Query below lists:

(A) distribution of column name lengths for all tables accessible to the current user in Oracle database

(B) distribution of column name lengths for all tables in Oracle database

Query was executed under the Oracle9i Database version.

Query

A. Tables accessible to the current user

select length(col.column_name) as column_name_length,
       count(*) as column_count,
       count(distinct col.owner || '.' || col.table_name) as table_count
from sys.all_tab_columns col
inner join sys.all_tables t on col.owner = t.owner 
                              and col.table_name = t.table_name
-- excluding some Oracle maintained schemas
where col.owner not in ('ANONYMOUS','CTXSYS','DBSNMP','EXFSYS', 'LBACSYS', 
   'MDSYS', 'MGMT_VIEW','OLAPSYS','OWBSYS','ORDPLUGINS', 'ORDSYS','OUTLN', 
   'SI_INFORMTN_SCHEMA','SYS','SYSMAN','SYSTEM', 'TSMSYS','WK_TEST',
   'WKPROXY','WMSYS','XDB','APEX_040000', 'APEX_PUBLIC_USER','DIP', 
   'FLOWS_30000','FLOWS_FILES','MDDATA', 'ORACLE_OCM', 'XS$NULL',
   'SPATIAL_CSW_ADMIN_USR', 'SPATIAL_WFS_ADMIN_USR', 'PUBLIC', 'WKSYS')  
group by length(col.column_name)
order by length(col.column_name);

B. If you have privilege on dba_tables and dba_tab_columns

select length(col.column_name) as column_name_length,
       count(*) as column_count,
       count(distinct col.owner || '.' || col.table_name) as table_count
from sys.dba_tab_columns col
inner join sys.dba_tables t on col.owner = t.owner 
                              and col.table_name = t.table_name
-- excluding some Oracle maintained schemas
where col.owner not in ('ANONYMOUS','CTXSYS','DBSNMP','EXFSYS', 'LBACSYS', 
   'MDSYS', 'MGMT_VIEW','OLAPSYS','OWBSYS','ORDPLUGINS', 'ORDSYS','OUTLN', 
   'SI_INFORMTN_SCHEMA','SYS','SYSMAN','SYSTEM', 'TSMSYS','WK_TEST',
   'WKPROXY','WMSYS','XDB','APEX_040000', 'APEX_PUBLIC_USER','DIP', 
   'FLOWS_30000','FLOWS_FILES','MDDATA', 'ORACLE_OCM', 'XS$NULL',
   'SPATIAL_CSW_ADMIN_USR', 'SPATIAL_WFS_ADMIN_USR', 'PUBLIC', 'WKSYS')  
group by length(col.column_name)
order by length(col.column_name);

Columns

  • column_name_length - length of the column name
  • column_count - number of columns having name of this length
  • table_count - number of tables having columns with name of this length

Rows

  • One row represents one column name length
  • Scope of rows: (A) distribution of column name lengths for all tables accessible to the current user in Oracle database, (B) distribution of column name lengths for all tables in Oracle database
  • Ordered by length of the column name

Sample results

If you put it into chart it looks like this:

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
0
There are no comments. Click here to write the first comment.