Exploring Oracle Data Dictionary, a htmSQL Utility Hsiwei Yu, Logicon, a Northrop Grumman Company, Herndon, Virginia Wen-Hsiung Lee, U.S. Environmental Protection Agency, Washington, D.C.
ABSTRACT SQL> desc all_synonyms; Name Null? Type SAS/Access to Oracle and htmSQL, part of SAS/IntrNet, allow us to ------develop a utility for querying Oracle’s data dictionary on Internet and OWNER NOT NULL VARCHAR2(30) obtain information such as column attributes in a table or simple SYNONYM_NAME NOT NULL VARCHAR2(30) statistics on a column. This utility can be modified to query DB2, TABLE_OWNER VARCHAR2(30) Sybase, or ODBC-compliant database. TABLE_NAME NOT NULL VARCHAR2(30) … … INTRODUCTION htmSQL application in SAS/IntrNet was widely used for querying SAS SQL> desc all_views; data dictionary, e.g. showing variable attributes in SAS dataset. We Name Null? Type found it’s also useful to help users to explore Oracle database’s ------structure dynamically on Internet. OWNER NOT NULL VARCHAR2(30) VIEW_NAME NOT NULL VARCHAR2(30) ORACLE DATA DICTIONARY TEXT_LENGTH NUMBER Of interest for Oracle data dictionary is a view named DICTIONARY, or TEXT LONG DICT. This view gives a complete list of data dictionary views. Columns … … in a data dictionary view can be further queried via the DICT_COLUMNS view. Therefore from the DICT view, we found some ARRANGE HTMSQL DRILL DOWN usage: Initially users can query all_tables to determine owners by this input hsql file: USAGE ORACLE VIEW NAME {QUERY DATASRC= ..}{SQL} Public tables for all users to read all_tables {* Oracle specific SQL statements. *} Column attribute information for all_tab_columns select owner, count(*) as counts each public table from all_tables Public synonyms for all users to all_synonyms group by owner read {/SQL} Public views for all users to read, all_views .. showing the SQL statements {EACHROW} defining each view
Similarly given specific owner value, users can find out synonym and See Figure 2 for a sample output for tables in an Oracle view owned by this owner, via Oracle’s all_synonyms and all_views. instance. COLUMN ATTRIBUTES IN A TABLE Then clicking on the table hyperlink, it will drill down to show the column attributes in a table, this paper. If SAS/Access to DB2 or Sybase licensed, or a {QUERY DATASRC= ..}{SQL} SAS/Share server running on PC environment, this utility can {* Oracle specific SQL statements. *} also be used for exploring DB2, Sybase, or ODBC-compliant select column_name, data_type .. RDBMS on Internet. from all_tab_columns where owner = ‘{&owner}’ REFERENCES and table_name = ‘{&table_name}’ Koch, G., and Loney, K., 1997. Oracle 8, the Complete {/SQL} Reference. Berkeley, CA: Osborne/McGraw-Hill .. {EACHROW}
{QUERY DATASRC= ..}{SQL} {* ODBC data source specific SQL statements. *} select table_name from ODBC::SQLTables {/SQL} .. {EACHROW}
CONCLUSION We have found the htmSQL utility was quite useful for us to gain familiarity with Oracle data. During implementation, we discovered some easy ways for exploring Oracle data structure, as described in Figure 1: Owners in an Oracle instance
Figure 2: Tables belonging to an owner Figure 3: Columns in a table
Figure 4: Column value frequency count