You are on page 1of 2

Whenever we create a table in database, description of that table is considered metadata and Oracle stores that metadata in its

data dictionary. Not just table, Oracle stores the definitions of all database objects we create like views, PL/ SQL packages, triggers, synonyms, indexes etc. In other words, The Oracle Database contains tables which describe what database objects i.e. tables, procedures, triggers etc. exist within the database. This information about the information is known as metadata. The database management system uses this metadata to properly manage stored data and also to interpret and execute SQL statements. As a DBA or a developer, we n eed to have knowledge on data dictionary of the database. Codd s fourth rule for relational database systems states that database metadata m ust be stored in relational tables just like any other type of data. Oracle expo ses database metadata through a large collection of data dictionary views. These Oracle s data dictionary views are mapped onto underlying base tables, but t he views are the primary interface to Oracle s metadata. The views return data in a much more understandable format than we will get from querying the underlying tables. Oracle recommends to use metadata views only. For example if we wanted to see all the tables that are created by my user then execute the below query. SELECT TABLE_NAME FROM user_tables; Oracle divides data dictionary views into the three families, as indicated by th e following prefixes: USER_ USER views return information about objects owned by the currently-logged-on database user. For example, a query to USER_TABLES returns a list of all of the relational tables that you own. ALL_ ALL views return information about all objects to which you have access, reg ardless of who owns them. For example, a query to ALL_TABLES returns a list not only of all of the relational tables that you own, but also of all relational ta bles to which their owners have specifically granted you access (using the GRANT command). DBA_ DBA views are generally accessible only to database administrators, and retu rn information about all objects in the database, regardless of ownership or acc ess privileges. For example, a query to DBA_TABLES will return a list of all rel ational tables in the database, whether or not you own them or have been granted access to them. Occasionally, database administrators will grant developers acc ess to DBA views. Usually, unless you yourself are a DBA, you won t have access to the DBA views. For example: A table is a schema object and owned by a user, hence the need for USER_TABLES. Table owners can grant specific users to access their tables, hence the need for ALL_TABLES. Database administrators need to be aware of all tables in the datab ase, hence the need for DBA_TABLES. Using this information, we can find all tables accessible by a user or get a lis t of stored procedures or get information about many other types of objects in a

n Oracle database. Same as below, we have USER_ and DBA_ views as well. (just prefix before the view na me like USER_TABLES) Following are Metadata views for Oracle Database. ALL_TABLES list of all tables in the current database that are accessible to the current user ALL_VIEWS list of all views in the current database that are accessible to t he current user ALL_TAB_COLUMNS list of all columns in the database that are accessible to t he current user ALL_ARGUMENTS lists the arguments of functions and procedures that are acces sible to the current user ALL_ERRORS lists descriptions of errors on all stored objects (views, proced ures, functions, packages, and package bodies) that are accessible to the curren t user ALL_OBJECT_SIZE included for backward compatibility with Oracle version 5 ALL_PROCEDURES (from Oracle 9 onwards) lists all functions and procedures (a long with associated properties) that are accessible to the current user ALL_SOURCE describes the text (i.e. PL/SQL) source of the stored objects acc essible to the current user [/List] Example 1: finding tables Find all tables in the database that have STUDENT in the table name SELECT TABLE_NAME FROM ALL_TABLES WHERE TABLE_NAME LIKE '%STUDENT%' ORDER BY TABLE_NAME; Example 2: finding columns Find all tables that have at least one column with SELECT FROM WHERE TABLE_NAME, COLUMN_NAME ALL_TAB_COLUMNS COLUMN_NAME LIKE '%SNO%'; SNO in the column name

For more details: check http://newtonapples.com/

You might also like