Oracle Data Dictionary
Oracle Data Dictionary
com/
These views describe the columns of tables, views, and clusters in the database. Some columns
in these views contain statistics that are generated by the DBMS_STATS package or ANALYZE
statement.
DBA_TAB_COLUMNS
ALL_TAB_COLUMNS
USER_TAB_COLUMNS
These views describe all relational and object tables in the database. Object tables are not
specifically discussed in this book..
DBA_ALL_TABLES
ALL_ALL_TABLES
USER_ALL_TABLES
These views display comments for tables and views. Comments are entered using the
COMMENT statement.
DBA_TAB_COMMENTS
ALL_TAB_COMMENTS
USER_TAB_COMMENTS
These views display comments for table and view columns. Comments are entered using the
COMMENT statement..
DBA_COL_COMMENTS
ALL_COL_COMMENTS
USER_COL_COMMENTS
These views list the specific attributes of external tables in the database.
DBA_EXTERNAL_TABLES
ALL_EXTERNAL_TABLES
USER_EXTERNAL_TABLES
These views provide column statistics and histogram information extracted from the related
TAB_COLUMNS views.
DBA_TAB_COL_STATISTICS
ALL_TAB_COL_STATISTICS
USER_TAB_COL_STATISTICS
These views describe tables that have been modified since the last time table statistics were
gathered on them. They are not populated immediately, but after a time lapse (usually 3 hours).
DBA_TAB_MODIFICATIONS
ALL_TAB_MODIFICATIONS
USER_TAB_MODIFICATIONS
These views list table columns that are encrypted, and for each column, lists the encryption
algorithm in use.
DBA_ENCRYPTED_COLUMNS
USER_ENCRYPTED_COLUMNS
ALL_ENCRYPTED_COLUMNS
These views list tables with unused columns, as marked by the ALTER TABLE ... SET UNUSED
statement.
DBA_UNUSED_COL_TABS
ALL_UNUSED_COL_TABS
USER_UNUSED_COL_TABS
These views list tables that have partially completed DROP COLUMN operations. These
operations could be incomplete because the operation was interrupted by the user or a system
failure.
DBA_PARTIAL_DROP_TABS
ALL_PARTIAL_DROP_TABS
USER_PARTIAL_DROP_TABS
ROW ID
Every row in every table has a physical address. The address of a row is determined from a
combination of
the following:
Datafile number.
Block number.
Location of the row within the block.
Object number.
You can display the address of a row in a table by querying the ROWID pseudo-columnfor
example:
ROWID EMP_ID
------------------ ---------
AAAFWXAAFAAAAlWAAA 1
You can translate the ROWID value into meaningful information via the DBMS_ROWID
package. For example,
select emp_id
,dbms_rowid.rowid_relative_fno(rowid) file_num
,dbms_rowid.rowid_block_number(rowid) block_num
,dbms_rowid.rowid_row_number(rowid) row_num
from emp;
You can use the ROWID value in the SELECT and WHERE clauses of a SQL statement. In most
cases, the
ROWID uniquely identifies a row.
Execution plans
------------------
1. Execute the SQL statement EXPLAIN plan, and then query the table where the output was
written.
2. Query a dynamic performance view showing the excution plans cached in the library cache.
3. Query an Automatic workload Repository or statspack table, showing the execution plans
stored in the repository.
1) SQL statement EXPLAIN plan (EXPLAIN PLAN is a statement for EXECUTION PLAN)
plan table --> where sql statemnet explian plan writes the output. -------------------------This query
use to diplay result
HOW WE CAN CRAETE A TAG AND HOW CAN DISPLAY WITH TAG.
-----------------------------------------------------
EXPLAIN PLAN set statement_id='myplan' into plan_table for select count(*) from dba_users;
NOTE: 1. We can mention "update statement" also in EXPLAIN PLAN query, that update action
wont affect the table,just getting how the query works..
Eg:
Four dynamic performance views show information about the cursors present in the library
cache.
v$sql_plan
v$sql_plan_statistics
v$sql_workarea
v$sql_plan_statistics_all
3) AWR/Statspack.
@$ORACLE_HOME/rdbms/admin/awrsqrpt.sql or awrsqlrpt.sql
OR
4) Traceing
NOTE: A trace generated only when a hard parse (means once we run new query in DB first
time) performed.
EVENT 10053:
***query***
EVENT 10132:
***query***
***query***
NOTE:
Here are some common acts that will change execution plans:
- Enabling parallelism
Rare Example:
Elapsed: 00:00:00.07
Execution Plan
----------------------------------------------------------
Plan hash value: 1584247153
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)|
----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 187 (4)|
|* 1 | HASH JOIN RIGHT SEMI | | 1 | 187 (4)|
| 2 | COLLECTION ITERATOR CONSTRUCTOR FETCH| | | |
| 3 | TABLE ACCESS FULL | T | 50096 | 161 (3)|
----------------------------------------------------------------------------
TABLE:
------
DB LINK:
--------
OR
TABLESPACE:
-----------
PACKAGE BACKUP
--------------
set heading off
set echo off
set flush off
set pagesize 50000
set linesize 32767
set long 99999999
spool PACKAGE_NAME.pks
select dbms_metadata.get_ddl('PACKAGE','','') from dual ;
spool off;
OR
OR
OR
set pagesize 0
set linesize 800
set trimspool on
set heading off
set feedback off
spool PACKAGE_BODY_NAME.pkb
select text from dba_source where owner=''and name='';
spool off
OR
We use this timestamp to manage dependencies between remote objects (eg: in a distributed
system where we have local procedures that call remote procedures -- we have to
invalidate local procedures that depend on remote procedures whose timestamps have
changed).
LAST_DDL_TIME = last ddl on object, would include CREATE OR REPLACE (example below)
TIMESTAMP = last time the external "view" or "specification" of the object changed --
will be between created and last_ddl_time.
View created.
tkyte@TKYTE816>
tkyte@TKYTE816> select timestamp, to_char(created,'hh24:mi:ss'),
2 to_char(last_ddl_time,'hh24:mi:ss')
3 from dba_objects
4 where object_name = 'V'
5 and owner = USER
6/
it starts with the timestamp = created = last_ddl_time. Now, lets alter the view
(doesn't change its EXTERNAL interface):
tkyte@TKYTE816>
tkyte@TKYTE816> exec dbms_lock.sleep(2)
tkyte@TKYTE816>
tkyte@TKYTE816> alter view v compile
2/
View altered.
Now, the timestamp did not change -- it is still the same as the created. The
last_ddl_time did however change as we just did some DDL on the view. We can in fact do
some DDL on the view you might think would change the timestamp:
tkyte@TKYTE816>
tkyte@TKYTE816> exec dbms_lock.sleep(2)
View created.
tkyte@TKYTE816>
tkyte@TKYTE816> select timestamp, to_char(created,'hh24:mi:ss'),
2 to_char(last_ddl_time,'hh24:mi:ss')
3 from dba_objects
4 where object_name = 'V'
5 and owner = USER
6/
But it does not -- the "signature" or external interface of the view did not change.
If we do a create or replace that changes the interface of the view:
tkyte@TKYTE816>
tkyte@TKYTE816> exec dbms_lock.sleep(2)
View created.
tkyte@TKYTE816>
tkyte@TKYTE816> select timestamp, to_char(created,'hh24:mi:ss'),
2 to_char(last_ddl_time,'hh24:mi:ss')
3 from dba_objects
4 where object_name = 'V'
5 and owner = USER
6/
TIMESTAMP TO_CHAR( TO_CHAR(
------------------- -------- --------
2000-12-13:13:11:32 13:11:26 13:11:32
tkyte@TKYTE816>
And so now the timestamp is different since the "specification" of this view is
different.