Professional Documents
Culture Documents
To check the Database name and ID SQL> select name , dbid from v$database; To check the database Version SQL> select * from v$version; To check the database Global name SQL> select * from global_name; To check the database Character set information SQL> select * from nls_database_parameters; To check the database current information SQL> select created, resetlogs_time, log_mode from v$database; To check the database instance name SQL> Select instance_name from v$instance; To check the database Edition SQL>select * from product_component_version; To check tablespace information in tahe database SQL>select * from v$tablespace;
To check database default information SQL> select username, profile, default_tablespace, temporary_tablespace from dba_users; To check the database host information SQL> select utl_inaddr.get_host_address, utl_inaddr.get_host_name From dual; To check TOTAL SIZE of the database SQL>select a.data_size + b.temp_size + c.redo_size TOT SIZE GB from (select sum(bytes/1024/1024/1024) data_size from dba_data_files ) a, (select nvl ( sum ( bytes/1024/1024/1024) ,0 ) temp_size from dba_temp_files ) b, (select sum(bytes/1024/1024/1024) redo_size from sys.v_$log ) c ; or
SQL> select ( select sum(bytes/1024/1024/1024) from dba_data_files) + (select sum ( bytes/1024/1024/1024) from dba_temp_files) DB Size in GB from dual; To check database and Instance last start time SQL> SELECT to_char(startup_time,'DD-MON-YYYY HH24:MI:SS') "DB Startup Time" FROM sys.v_$instance; SQL> SELECT SYSDATE-logon_time "Days", (SYSDATE-logon_time)*24 "Hours" from sys.v_$session where sid=1; Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
To track the database structure linux>$ vi . trrackdb.sql Select name from sys.v_$controlfile / select group#,member from sys.v_$logfile / Select F.file_id Id, F.file_name name, F.bytes/(1024*1024) Mbyte, decode(F.status,'AVAILABLE','OK',F.status) status, F.tablespace_name Tspace from sys.dba_data_files F order by tablespace_name; SQL>@trackdb.sql ; To check the current size of the tablespace SQL>select sum (bytes/1024/1024/1024) Size in GB from dba_data_files where tablespace_name=<TABLESPACE_NAME>; To check free space of the tablespace SQL> select sum(bytes/1024/1024/1024) from dba_free_space where tablespace_name=<TABLESPACE_NAME>; To check free size of the table space SQL> select sum(bytes/1024/1024/1024) from dba_free_space where tablespace_name=<TABLESPACE_NAME>; To check size of the schema table SQL> select sum(bytes/1024/1024) from dba_segments where owner='<OWNER_NAME>' and segment_name='DEPT'; Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
To list all users in the database SQL> select username from dba_users; To check the default tablespace of the user SQL> select default_tablespace from dba_users where username='SCOTT'; To create a user and assigning tablespace SQL> create user <USERNAME> identified by <PASSWORD> default tablespace <DEFAULT_TABLESPACE_NAME> temporary tablespace <TEMPORARY_TABLESPACE_NAME> ; SQL> create user sam identified by sam default tablespace users temporary tablespace temp; SQL>select username , default_tablespace , temporary _ table space from dba_users where username='SAM'; To lock and unlock user account SQL> alter user <USERNAME> account lock; SQL> alter user <USERNAME> account unlock; To change user password
champ
SQL> alter user <USERNAME> identified by <PASSWORD>; SQL> alter user scott identified by tiger; To drop a user along with objects SQL> drop user <USERNAME> CASCADE; Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
To list all the objects of a user SQL> select object_name, object_type from dba_objects Where owner='SCOTT'; To list sid and serial# of the session SQL> select sid , serial#, username, status from v$session; To kill a oracle session; SQL> ALTER SYSTEM KILL SESSION 'sid,serial#'; How to kill oracle sessions USER is "SYS" SQL> select sid, serial#, username, status from v$session;
SID SERIAL# USERNAME STATUS
141 142
48 82
SYS SCOTT
ACTIVE INACTIVE
SQL> alter system kill session '142,82'; System altered. SQL> show user; USER is "SCOTT" SQL> select * From tab; select * From tab * ERROR at line 1: ORA-00028: your session has been killed.
Alternative Method for killing oracle sessions USER is "SYS" SQL> alter system disconnect session 'sid,serial#' post_transaction; SQL> alter system disconnect session 'sid,serial#' immediate; SQL>alter system disconnect session '150,143' post_transaction; SQL>alter system disconnect session '150,143' immediate;
USERS / SESSIONS / PROCESSESS details
Track LOGON Time of DBUSER and OSUSER SQL>select to_char(logon_time, 'dd-mm-yyyy hh24:mi:ss'), osuser, status, schemaname, machine from v$session where type !='BACKGROUND'; Track all Sessions user details SQL> select sid, serial#, machine, status, osuser, username from v$session where username!= 'NULL'; Track Active/Inactive Sessions user details SQL>select sid, serial#, username, status, schemaname, logon_time from v$session where status= 'ACTIVE' AND username IS NOT NULL; SQL>select sid, serial#, username, status, schemaname, logon_time from v$session where status= 'INACTIVE' AND username is NOT NULL; Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
Track Active User details SQL>SELECT s.inst_id, s.sid, s.serial#, p.spid, s.username, s.program 2 FROM gv$session s JOIN gv$process p ON 3 p.addr = s.paddr AND 4 p.inst_id = s.inst_id 5 WHERE s.type != 'BACKGROUND' ;
Tracking ACTIVE SESSION USER INFO Vs ACTIVE USER INFO TERMINAL 1:
SQL> show user; USER is "SAM" SQL> update tab2 set email='sam.dba@gmail.com'; Update process is ...... running ...... running ..
TERMINAL 2 :
SQL> show user; USER is "SYS" Here , tracing Active Session user details SQL> select sid, serial#, username, status, schemaname, logon_time FROM V$Session WHERE status= 'ACTIVE' and username IS NOT NULL;
SID SERIAL# USERNAME STATUS SCHEMANAME LOGON_TIM
141 143
62 33537
SAM SYS
ACTIVE ACTIVE
SAM SYS
04-JUL-13 04-JUL-13
In terminal 1 , all rows has been updated by SAM user ! SQL> select sid, serial#, username, status, schemaname, logon_time FROM V$session where status= 'ACTIVE' and username IS NOT NULL;
SID SERIAL# USERNAME STATUS SCHEMANAME LOGON_TIM
143
33537
SYS
ACTIVE
SYS
04-JUL-13
Here , trying to trace Active user details SQL> SELECT s.inst_id, s.sid, s.serial#, p.spid, s.username, s.program 2 FROM gv$session s JOIN gv$process p ON 3 p.addr = s.paddr AND 4 p.inst_id = s.inst_id 5 WHERE s.type != 'BACKGROUND';
INST_ID SID SERIAL# SPID USERNAME PROGRAM
1 1 1 1
5 29863 62 33537
SYS
SAM SYS
are continuously updated while a database is open and in use and their contents primarily related to performance. Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
Almost every V$view, Oracle has a corresponding GV$ (global V$) view each GV$ view contains an extra column named INST_ID of datatype NUMBER. The INST_ID displays the instance number. v$session for single instance. gv$session for RAC ( multiple Instance). Only difference is column name "INST_ID" by using this INST_ID can differentiate Instances in RAC. V$PROCESS displays information about the currently active processes. V$SESSION lists session information for each current session.
COLUMN V$PROCESS V$SESSION
SID PID SPID ADDR * SADDR PADDR * SERIAL # USERNAME PROGRAM Oracle process Identifier O.S process Identifier Address of the process state object --------------Process serial number O.S process username Program in progress
Session Identifier ---------------------Session Address Address( process) owns session Session serial number Unique Oracle username O.S Program name
STATUS (V$SESSION)
ACTIVE or INACTIVE KILLED - Session marked to be killed. CACHED - Session temporarily cached for use by Oracle *XA SNIPED - - Session inactive, waiting on the client. Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
Tracing DBUSER Checking Active users in my database SQL>select sid, serial#, username, status, schemaname, FROM V$session where status= 'ACTIVE' and username IS NOT NULL;
SID SERIAL# USERNAME STATUS SCHEMANAME
9 12 16 12 11
Tracing PID , USERNAME etc .. from OS - LEVEL $ ps -e o pcpu, pid, user, tty, args | grep -I oracle | sort -n -k 1 -r |head 1.7 7638 oracle ? oracleorclprod
(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq))) 0.9 7083 oracle ? 0.7 6944 oracle ? default4 0.6 7818 oracle ? oracleorclprod ora_lgwr_orclprod /usr/bin/python /usr/bin/rhn-applet-gui --sm-client-id
oracleorclprod
(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq))) 0.2 7105 oracle ? 0.2 7103 oracle ? 0.1 9519 oracle ? ora_arc1_orclprod ora_arc0_orclprod ora_j000_orclprod
SYS> select s.username "DB_USER", p.username "OS_USER" , p.spid 2 from v$process p , v$session s where p.addr=s.paddr and s.username is not null;
Simple query to find addr(v$session) = paddr(v$process) SQL> select s.username , p.username , p.spid , s.paddr , p.addr 2 from v$session s , v$process p 3 where p.addr=s.paddr and 4 s.username is not null ; Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
Important Objects Information Reporting all Invalid objects in database SQL> SELECT owner , object_name , object_type , TO_CHAR (last_ddl_time, 'DD-MON-YY hh24:mi:ss' ) last_time FROM dba_ob ects WHERE status = 'INVALID' ; or SQL> select object_name , status from dba_objects where status='INVALID'; Count Invalid Objects SQL> select owner, object_type, count(*) from dba_objects where status='INVALID' group by owner, object_type ; Number of objects created in last week SQL> select count(*) " COUNT OF LAST WEEK CREATION" from user_objects where CREATED > = sysdate -7;
Track M.Views refreshed or not since last week SQL> select mview_name from user_mviews where LAST_REFRESH_DATE < sysdate - 7; Track total no of Tables SQL> select count(*) from user_tables; SQL> select count(*) from all_tables; SQL> select count(*) from user_tables t where table_name NOT IN ( select object_name from user_recyclebin r where r.type = 'TABLE' ); Query to find database largest objects SQL> select * from (select SEGMENT_NAME, SEGMENT_TYPE, BYTES/1024/1024/1024 GB, TABLESPACE_NAME from dba_segments order by 3 desc ) where rownum <= 5; Database objects Information SQL> select owner ,object_type , count(*) from dba_objects where owner not IN ( 'SYS','MDSYS', 'CTXSYS', 'HR', 'ORDSYS', 'OE', 'ODM_MTR' , 'WMSYS', 'XDB', 'QS_WS', 'RMAN', 'SCOTT', 'QS_ADM', 'QS_CBADM', 'ORDSYS','OUTLN','PM','QS_OS','QS_ES','ODM','OLAPSYS','WKSYS','SH', 'SYSTEM','ORDPLUGINS','QS','QS_CS' ); Information about segment level statistics SQL> select * from v$segment_statistics where owner ='schema owner' and object_name = 'TABLE_ NAME ';
lets to see many different statistics on the usage of segments since instance startup. In Oracle database , a segment is any database object that requires
physical storage space, Segments include tables, indexes, clusters, partitions, temporary segments, undo segments, and LOB segments. Definition of all segments reside in the data dictionary. Objects like views, procedures, triggers are not included in the list of segments. These objects do not need to allocate an extent to reside in the database. They are only stored in the data dictionary.
V$SEGMENT_STATISTICS. There is a easy way to get information or
statistics about the usage of various segments ; Who wants to know physical reads or writes occurred on a specific table. SQL> select distinct statistic_name from v$segment_statistics ;
STATISTIC_NAME
gc buffer busy db block changes space used segment scans gc cr blocks received gc current blocks received row lock waits Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
buffer busy waits physical reads physical reads direct physical writes space allocated logical reads physical writes direct ITL waits Information about segment level statistics is found in
V$SEGMENT_STATISTICS
We can see information about logical reads, logical writes, physical reads, physical writes, direct path reads and writes, etc . Check
metalink Note:252597.1 (Relation between Table Monitoring and STATISTICS_LEVEL parameter in 10g) ,
Script Segments with highest I/O activity This script will list the top 10 segments in the database that have the most number of physical reads. SQL> select segment_name , object_type , total_physical_reads 2 from (select owner||'.'||object_name as segment_name , 3 object_type, value as total_physical_reads 4 from v$segment_statistics 5 where statistic_name in ('physical reads') 6 order by total_physical_reads desc) 7 where rownum <=10;
SQL> select statistic_name, value from v$segment_statistics where owner='SAM' and object_name='TAB1' and statistic_name='physical reads'; Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
To determine top 10 tables most physical I/O SQL> select table_name, total_phys_io from (select owner ||'.'|| object_name as table_name, sum(value) as total_phys_io from v$segment_statistics where owner!='SYS' and object_type='TABLE' and statistic_name in ('physical reads', 'physical reads direct', 'physical writes', 'physical writes direct') Group by owner||'.'|| object_name Order by total_phys_io desc ) where rownum <=10;
Busy buffer waits buffer busy waits event - This event occurs when one session is waiting on another session to read the buffer into the cache, or some her session is changing the buffer. This even can often be seen when querying V$SYSTEM_EVENT. Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
V$SYSTEM_EVENT contains information on total waits for an event. SQL> select event, total_waits from v$system_event 2 where event='buffer busy waits'; Query to find top 'buffer busy waits' SQL> select segment_name, object_type, total_buff_busy_waits from ( select owner||'.'||object_name as segment_name, object_type, value as total_buff_busy_waits from v$segment_statistics where statistic_name in ('buffer busy waits') order by total_buff_busy_waits desc) where rownum <=10; The V$SEGMENT_STATISTICS dynamic performance view gives many statistics about each and every segment that is used by the database. Query to check the schema growth SQL> select obj.owner "Owner", obj_cnt "Objects", decode(seg_size, NULL, 0, seg_size) "Size in MB" from (select owner, count(*) obj_cnt from dba_objects group by owner) obj, (select owner, ceil(sum(bytes)/1024/1024) seg_size from dba_segments group by owner) seg where obj.owner = seg.owner(+) order by 3 desc , 2 desc, 1;
Displaying SEGMENT Information SQL> select segment_name, tablespace_name, bytes, blocks, extents from dba_segments where segment_type = 'TABLE' and owner='SAM' order by segment_name; Displaying SEGMENT Information on specific object SQL> select segment_name, tablespace_name, bytes , blocks, extents from dba_segments segment_name='TAB1' and owner='SAM'; Displaying EXTENT Information on specific object SQL> select segment_name, segment_type, tablespace_name, extent_id, bytes, blocks from dba_extents where segment_name='TAB1' and owner='SAM' order by segment_name ; Query to find tablespaace details SQL> select t.tablespace,t.totalspace as "TOTAL_SPACE(MB)", round((t.totalspace-fs.freespace),2) as "USED_SPACE(MB)", fs.freespace as "FREE_SPACE(MB)", round(((t.totalspace-fs.freespace)/t.totalspace)*100,2) as "% Used", round((fs.freespace/t.totalspace)*100,2) as "% Free" From (select round(sum(d.bytes)/(1024*1024)) as totalspace, d.tablespace_name tablespace from dba_data_files d group by d.tablespace_name) t, (select round(sum(f.bytes)/(1024*1024)) as freespace , f.tablespace_name tablespace from dba_free_space f group by f.tablespace_name) fs where t.tablespace=fs.tablespace order b y t.tablespace;
To check free space for all tablespaces SQL> select tablespace_name , sum(bytes/1024/1024) " SIZE in MB" from dba_free_space group by tablespace_name; SQL> select tablespace_name , sum(bytes/1024/1024) " SIZE in MB" from sm$ts_free group by tablespace_name; To Monitor Table space Growth Datafilewise SQL> SELECT /*+ ordered */ d.tablespace_name tablespace , d.file_name filename , d.file_id file_id , d.bytes filesize
, NVL((d.bytes - s.bytes), d.bytes) used , TRUNC(((NVL((d.bytes - s.bytes) , d.bytes)) / d.bytes) * 100) pct_used FROM sys.dba_data_files d , v$datafile v , ( select file_id, SUM(bytes) bytes from sys.dba_free_space GROUP BY file_id) s WHERE (s.file_id (+)= d.file_id) AND (d.file_name = v.name) UNION SELECT d.tablespace_name tablespace , d.file_name filename , d.file_id file_id , d.bytes filesize , NVL(t.bytes_cached, 0) used , TRUNC((t.bytes_cached / d.bytes) * 100) pct_used FROM sys.dba_temp_files d , v$temp_extent_pool t , v$tempfile v WHERE / (t.file_id (+)= d.file_id) AND (d.file_id = v.file#)
Checking autoextend ON/OFF for datafile S L> select tablespace_name,AUTOEXTENSIBLE from dba_data_files; SQL> select substr(file_name,1,50), autoextensible from dba_data_files Checking datafile with highest I/O activity S L> Select * from (select name, phyrds, phywrts, readtim, writetim from v$filestat a, v$datafile b where a.file#=b.file# order by readtim desc) where rownum <6 ;
Query to find which user is using Temporary Tablespace SQL> select username , tablespace , sql_id from v$tempseg_usage; Or SQL>select S.sid, S.username, U.tablespace, S.sql_hash_value||'/'||U.sqlhash hash_value, U.segtype, u.contents, U.blocks from v$session S, v$tempseg_usage U where S.saddr=U.session_addr order by U.blocks; Or SQL> select S.sid, S.username "DB_USER", P.username "OS_USER" , P.spid, U.tablespace, S.sql_hash_value||'/'||U.sqlhash HASH_VALUE , U.segtype, U.contents, U.blocks from v$process p , v$session S , v$tempseg_usage U where S.saddr=U.session_addr and p.addr=s.paddr order by U.blocks; Track Default and Temporary Tablespace SQL> select S.sid, S.username "DB_USER", P.username "OS_USER" , P.spid, U.tablespace, S.sql_hash_value||'/'||U.sqlhash HASH_VALUE , U.segtype, U.contents, U.blocks from v$process p , v$session S , v$tempseg_usage U where S.saddr=U.session_addr and p.addr=s.paddr order by U.blocks;; Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
Tracking SQL being executed by a OS Process ID (PID) SQL> select s.username "USER_NAME", substr(sa.sql_text,1,540) "SQL_TEXT" from v$process p, v$session s, v$sqlarea sa where p.addr=s.paddr and s.username is not null and s.sql_address=sa.address(+) and s.sql_hash_value=sa.hash_value(+) and spid=&SPID;
SCRIPT - SQL being executed by a particular SID SQL>select q.sql_text from v$session s , v$sql q WHERE s.sql_address = q.address and s.sql_hash_value + DECODE (SIGN(s.sql_hash_value), -1, POWER( 2, 32), 0) = q.hash_value AND s.sid=&1;
application designers and database administrators). SQL statements to access the data dictionary; because it is READ-ONLY. We can issue only queries (SELECT statements) against it's tables and views.
STRUCTURE OF DATA DICTIONARY :
Data dictionary consists BASE TABLES and USER ACCESSIBLE VIEWS. Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
BASE TABLES The original tables that store information about the associated database. Only Oracle should write to and read these tables. Users rarely access them directly because they are normalized, and most of the data is stored in a cryptic format. USER - ACCESSIBLE VIEWS The views that displays information stored in the base tables of the data dictionary. (These views decode the base table data into useful information), - mostly users are given access to the views rather than the BASE TABLES. POINTS TO NOTE The oracle super user SYS owns all base tables and user-accessible views of the data dictionary. SYS is the owner. No data in any DATA
DICTIONARY table should be altered or deleted by any user.
During database operation , Oracle updates the data dictionary continuously to reflect changes in database structures, auditing, grants, and data. Manually altering data in data dictionary affects database. If user SAM creates a table named SAMPLE, then new rows are added to the data dictionary that reflect the new table, columns, segment, extents, and the privileges that SAM has on the table. This new information is visible the next time the dictionary views are queried
How the Data dictionary is used The Data dictionary has three primary uses: Oracle accesses the data dictionary to find information about users, schema objects, and storage structures. Oracle modifies the data dictionary every time that a data definition language (DDL) statement is issued. Any Oracle user can use the data dictionary as a read-only reference for information about the database. POINTS TO NOTE
Oracle creates PUBLIC SYNONYMS for many data dictionary views so users can access them conveniently. Much of the data dictionary information is kept in the SGA in the
DICTIONARY CACHE, because Oracle constantly accesses the data
dictionary during database operation to validate user access and to verify the state of schema objects. All information is stored in memory using the least recently used (LRU) algorithm. Any Oracle user can use the data dictionary as a read-only reference for information about the database. Some views are accessible to all Oracle users, and others are intended for database administrators only. The data dictionary is always available when the database is open.
Data dictionary resides in the SYSTEM tablespace, which is always online. As I said , the data dictionary consists of sets of views. The dictionary views come in forms of DBA_ DBA_ ALL_
ALL_
USER_
USER_ : USERS VIEW Views with the Prefix DBA DBA_ Views with prefix DBA_ Includes all the objects in the database. A user must have DBA privileges to use this view. DBA views should be queried only by administrators. SQL>select owner, object_name, object_type from SYS.DBA_OBJECTS; SQL>select count(*) from SYS.DBA_OBJECTS; Views with the Prefix USER
USER_
Views with the prefix USER_ Objects owned by user; it Includes only the objects in the user's own database schema. Following query returns all the objects contained in own schema. SQL>select object_name, object_type from USER_OBJECTS; Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
Views with the Prefix ALL ALL_ Views with the prefix ALL_ refer to the user's information about
schema objects to which the user has access through public or explicit grants of privileges and roles. (objects to which user has privileges). This means , there are three views that relate to tables ;
DBA_CATLOG DBA_EXTENTS
DBA_CATALOG OWNER TABLE_NAME TABLE_TYPE DBA_EXTENTS OWNER SEGMENT_NAME PARTITION_NAME SEGMENT_TYPE
ALL_ ( NONE )
ALL_CATALOG OWNER TABLE_NAME TABLE_TYPE
ALL_EXTENTS -------
TABLESPACE_NAME EXTENT_ID EXTENT_ID FILE_ID BLOCK_ID BYTES BLOCKS ELATIVE_FNO Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu BYTES BLOCKS
POINTS TO NOTE Not all views sets have three members. For example, The Data dictionary contains a DBA_LOCK VIEW , but no ALL_LOCK/USER_LOCK View. DBA_SEGMENTS and USER_SEGMENTS VIEW in oracle , but no
ALL_SEGMENTS View.
Dynamic Performance Views Oracle database maintains a set of virtual tables that record current database activity and (storing data about instance). These views are called DYNAMIC PERFORMANCE VIEWS - (V$VIEWS) because they (collect data on internal disk structures and memory structures).So they are continuously updated while a database is open and in use.
DYNAMIC PERFORMANCE VIEWS are sometimes called FIXED
administrator. However, database administrators can query and create views on the tables and grant access to these views to other users.
V$VIEWS contain information about
System and session parameters Memory usage and allocation File states (including RMAN backup files) Progress of jobs and tasks SQL execution Statistics and metrics Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
POINTS TO NOTE
DYNAMIC PERFORMANCE VIEWS are identified by the prefix V_$. PUBLIC SYNONYMS for these views have the prefix V$. Database
administrators and other users should access only the V$ objects, not the V_$ objects. DYNAMIC PERFORMANCE VIEWS (V$VIEWS) V$ACCESS V$BACKUP V$BGPROCESS V$CACHE V$CONTROLFILE V$DATABASE V$DATAFILE V$INSTANCE V$LOCK V$LOGFILE V$LOGHIST V$PARAMETER V$PROCESS V$SESSION V$SQLAREA V$QL V$TABLESPACE V$TEMPFILE V$SGA V$VERSION
What is V$FIXD_TABLE The X$tables are FIXED-TABLES. Oracle created V$VIEWS on the X$ TABLES to make it easier to see Oracle internal details. The x$ fixed tables all have cryptic names. v$fixd_table this view displays all dynamic performance tables, views, and derived tables. SQL> select count(*) from v$FIXED_TABLE; SQL> select * from v$fixed_table where name like 'X%'; SQL> select counT(*) from v$fixed_table where name like 'X%';. We can easily see the source for all of the V$VIEWS by querying the V$FIXED_VIEW_DEFINITION view. S L>select * from v$fixed_view_definition where view_name=V$SESSION; Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
Getting access to X$tables SQL> grant select on X$KQFTA to scott; grant select on X$KQFTA to scott * ERROR at line 1: ORA-02030: can only select from fixed tables/views Why cant I GRANT access to X$ tables ? The X$ tables are fixed-tables. Fixed tables are not real tables! Fixed tables are defined directly in the Oracle source code and are based directly off of the C structures used in the database kernel. Is there any way to get around a direct GRANT ? Of course! The best way to do this is to create a view for each X$ table you want to GRANT access to. SQL> CREATE VIEW v_x$ksled AS SELECT * FROM X$KQFTA; View created. SQL> DROP view v_x$ksled View dropped. Why are the Oracle x$tables hidden ? Most hidden area of oracle database is Oracle x$ "tables". Oracle builds V$views upon the Oracle x$tables (which are actually mapped in-memory C program structures) and the x$ tables and columns are undocumented and change with each release. x$ "tables" are mostly instance or session memory structures presented as tables and serve as base tables of most V$ VIEWS.
POINTS TO REMEMBER: The database library is built on a Data dictionary.. The data dictionary is created when the Oracle database is created. It is owned by the SYS user and stored in SYSTEM tablespace. Some components are stored in SYSAUX tablespace in Oracle 10g. The data dictionary is comprised of a number of tables and Oracle views and it is available to all users . according to their privilege. The data dictionary views come in Three main flavors: USER_ ALL_ DBA_
The DICTIONARY or DICT (short) all the tables of the data dictionary, plus comments . We can see all data dictionary by running following query ; SQL> SELECT * FROM DICT ; SQL> SELECT * FROM DICTIONARY ; SQL> desc dict; SQL> select comments 2 FROM dictionary WHERE table_name='DICTIONARY'/
COMMENTS
Description of data dictionary tables and views Oracle maintains a set of virtual tables that record current database activity. These tables are created by Oracle . DYNAMIC PERFORMANCE VIEWS are based on virtual tables built from database memory structure, read
consistency is not guaranteed for the views because the data is updated dynamically.
V$ Dynamic Performance Views - These views are used to monitor real time database statistics
DYNAMIC PERFORMANCE VIEWS are not true tables, the data is dependent
on the state of the database and instance. For ex : We can query V$INSTANCE and V$BGPROCESS when the database is started but not mounted. However, we cannot query V$DATAFILE until the database has been mounted. Views that start with "V$" are referred to as dynamic performance views. Views that start with the "DBA" prefix are owned by the user SYS. Views that start with the prefix "ALL" keep track of all database objects that an end-user can access. Views that start with the prefix "USER" only contain information about objects owned by the user. V$FIXED_TABLE displays all dynamic performance tables, views, and derived tables in the database. Oracle Data dictionary views and Dynamic Performance Views DATA DICTIONARY and DYNAMIC PERFORMANCE (VIEWS) ALL_USERS ALL_TABLES USER_USERS USER_TABLES DBA_USERS DBA_TABLES DBA_TRIGGERS DBA_OBJECTS DBA_VIEWS DBA_INDEXES V$ACCESS V$BACKUP V$LOG V$LOGFILE V$INSTANCE V$SGA
Information about all users in the database DBA_USERS Information about all constraints in the database DBA_CONSTRAINTS Information about all table columns that have constraints on them DBA_CONS_COLUMNS Information about all columns that have indexes on them in the db DBA_IND_COLUMNS Information about all columns in all the tables in the database DBA_TAB_COLUMNS Information all about roles in the database DBA_ROLES Information about all object privileges in the database DBA_TAB_PRIVS All system privileges granted to all users in the database DBA_SYS_PRIVS Displays all PL/SQL source code in the database DBA_SOURCE Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
Information about all triggers in the database DBA_TRIGGERS Information about object privileges granted to roles ROLE_TAB_PRIVS Information about system privileges granted to roles ROLE_SYS_PRIVS Information about roles granted to roles ROLE_ROLE_PRIVS Information about all tablespaces in the database DBA_TABLESPACES Information about all profiles in the database DBA_PROFILES
V$PARAMETER
General information about the database mounted to your instance V$DATABASE Most information about the performance of the database is kept here V$SYSSTAT
Information about the performance for individual user sessions are V$SESSION , V$SESSTAT Information about online redo logs (2) V$LOG, V$LOGFILE Information about datafiles V$DATAFILE Basic information about control files, and the two columns it has: V$CONTROLFILE. STATUS / NAME An object can query to obtain a listing of all data dictionary objects (4) CATALOG, CAT, DICTIONARY , DICT. When the control file was created, Sequence Number, most recent SCN: V$DATABASE Information stored in different sections of the control file, Sequence no V$CONTROLFILE_RECORD_SECTION To see the names and locations of all control files in the databaseb(2) V$PARAMETER. V$CONTROLFILE
STORAGE STRUCTURES
All types of segments and their storage parameters, space utilization DBA_SEGMENTS Tablespace quotas assigned to users: DBA_TS_QUOTAS Segment details total bytes of extent, tablespace and storing the extent: DBA_EXTENTS Location and amount of free space by tablespace name: DBA_FREE_SPACE The location of free space in the tablespace that has been coalesced DBA_FREE_SPACE_COALESCED Information about datafiles for every tablespace DBA_DATAFILES Performance view for information for datafiles for every tablespace V$DATAFILE To see the total amount of space allocated to a table DBA_EXTENTS
Table creation timestamp, information about the object ID DBA_OBJECTS High water mark, all storage settings for a table, and statistics collected as part of the analyze (for row migration) operation on that table DBA_TABLES Information about every column in every table: DBA_TAB_COLUMNS To determine how many columns are marked unused for later removal? DBA_UNUSED_COL_TABS To find the number of deleted index entries ? INDEX_STATS To determine the columns on a table that have been indexed DBA_ID_COLUMNS Dynamic view to show whether the index is being used V$OBJECT_USAGE To see whether a constraint exists on a particular column DBA_CONS_COLUMNS
To see the constraints associated with a particular table DBA_CONSTRAINTS To find user details like ( username, ID number, (encrypted) password, default and temporary tablespace information, user profile etc .. ) DBA_USERS All objects, which objects belong to which users, user created Objects DBA_OBJECTS Resource-usage parameters for a particular profile DBA_PROFILES Identifies all resources in the database and their corresponding cost RESOURCE_COST Identifies system resource limits for individual users USER_RESOURCE_LIMITS Shows all system privileges DBA_SYS_PRIVS Show all object privileges DBA_TAB_PRIVS
Shows all privileges in this session available to you as the current user SESSION_PRIVS Views for audits currently taking place are created by this script cataudit.sql List of audit entries generated by the exists option of the audit command DBA_AUDIT_EXISTS A list of audit entries generated for object audits DBA_AUDIT_OBJECT A list of audit entries generated by session connects and disconnects DBA_AUDIT_SESSION A list of audit entries generated by statement options of the audit DBA_AUDIT_STATEMENT A list of all entries in the AUD$ table collected by the audit command DBA_AUDIT_TRAIL To determine the roles available in the database, the names of all the roles on the database and if a password is required to use each role DBA_ROLES
Names of all users and the roles granted to them DBA_ROLE_PRIVS All the roles and the roles that are granted to them ROLE_ROLE_PRIVS Which system privileges have been granted to a role DBA_SYS_PRIVS All the system privileges granted only to roles ROLE_SYS_PRIVS All the object privileges granted only to roles ROLE_TAB_PRIVS All the roles available in the current session SESSION_ROLES Which object privilege has been granted to a role DBA_TAB_PRIVS To display the value of the NLS_CHARACTERSET parameter NLS_DATABASE_PARAMETERS