You are on page 1of 3

Useful command

Show Oracle version:


COL PRODUCT FORMAT A35 COL VERSION FORMAT A15 COL STATUS FORMAT A15 SELECT * FROM PRODUCT_COMPONENT_VERSION; or: select * from v$version;

Show all tables:


select table_name from all_tables OR: select table_name from tabs;

Log as
root# su - oracle #sqlplus "/ as sysdba"

Database tablespaces and datafiles


select a.name tablespace, b.file# id, b.name datafile from v$tablespace a, v$datafile b where a.ts#=b.ts#;

Listener status:
#srvctl status listener

Check voting Disk:


crsctl query css votedisk

Size of sga memory regions:


SELECT NAME, SUM(BYTES) ROLLUP (NAME); SELECT NAME, SUM(BYTES) ROLLUP (NAME); FROM FROM V$SGASTAT V$SGASTAT WHERE WHERE pool='large pool='shared pool' pool' GROUP GROUP BY BY

select * from ( select POOL, NAME, BYTES, BYTES/1048576 as MBytes from v$sgastat where pool='large pool' order by BYTES desc ) where rownum <= 25;

select * from ( select POOL, NAME, BYTES, BYTES/1048576 as MBytes from v$sgastat where pool='shared pool' order by BYTES desc ) where rownum <= 25;

Extract AWR reports:


@?/rdbms/admin/awrrpt.sql (Type: html)

Extract ADDM reports:


@?/rdbms/admin/addmrpt.sql (Type: html)

Show tablespace usage


select tsname tablespace_name, Allocated_Mb, Used_Mb, round(100*used_mb/allocated_mb,2) as pct_used from ( select df.tablespace_name tsname, sum (df.bytes)/1024/1024 Allocated_Mb from sys.dba_data_files df group by df.tablespace_name), (select s.tablespace_name tsname2, sum (s.bytes)/1024/1024 Used_Mb from sys.dba_segments s group by s.tablespace_name) where tsname = tsname2;

Show all indexes


select owner, index_name, table_type, tablespace_name from dba_indexes where owner <>'SYSTEM' and owner <> 'DBSNMP' and owner <> 'ORDSYS' and owner <> 'OUTLN' and owner <> 'SYS' and owner <> 'SYSTEM' order by owner, index_name, tablespace_name

Show what a current user is doing:


select sid, 'User_name'; serial#, status, server from v$session where username =

Show segments size in tablespace:


Select segment_name, segment_type, /* TABLE,INDEX */ extents, /* No. of extents in the segment*/ blocks, /* No. of db blocks in the segment*/ bytes /* No. of bytes in the segment*/ From dba_segments

Where owner NOT IN('SYSTEM','DBSNMP', tablespace_name='TBS_INAPPL_IDX' Order By bytes ;

'ORDSYS',

'OUTLN','SYS')

and

Space used in each Segment:


SET LINESIZE 150 COLUMN tablespace_name FORMAT A15 COLUMN owner FORMAT A10 COLUMN segment_name FORMAT A35 COLUMN segment_type FORMAT A10 COLUMN extents FORMAT 9,999 COLUMN blocks FORMAT 999,999 COLUMN bytes FORMAT 999,999,999,999 Select tablespace_name, owner, segment_name, segment_type, /* TABLE,INDEX */ extents, /* No. of extents in the segment*/ blocks, /* No. of db blocks in the segment*/ bytes /* No. of bytes in the segment*/ From dba_segments Where owner NOT IN('SYSTEM','DBSNMP', 'ORDSYS', 'OUTLN','SYS') Order By bytes ; select username from dba_users;

You might also like