Oracle how to get an object Id from the rowid

 Oracle how to get an object Id from the rowid

=================================


select dbms_rowid.rowid_object('<RowID>') from dual;


select data_object_id, object_name, object_type from dba_objects where data_object_id in ('<OBJECT_ID>');

Oracle how to save output of the script in xls or html.

 Oracle how to save output of the script in xls or html:

=========================================


SET MARKUP HTML ON

SPOOL <file_name>.xls


or

SET MARKUP HTML ON

SPOOL <file_name>.html


How to check compression enabled on partition table

 

How to check compression enabled on partition table

=======================================


select

a.partition_name, a.tablespace_name, a.compression, a.compress_for , round(sum(a.num_rows / a.blocks),0) rows_per_block,

sum(a.num_rows) num_rows, sum(a.blocks) blocks , sum(b.bytes) /(1024*1024) mb

from dba_tab_partitions a, dba_segments b

where

a.table_name = 'TESTCOMP' and

a.partition_name = b.partition_name and

a.table_name = b.segment_name

group by a.partition_name, a.tablespace_name, a.compression, a.compress_for

order by 1;

Disable Constraints & Enable Constraints

 Disable Constraints & Enable Constraints :

===============================


DISABLE:

select 'alter table '||owner||'.'||table_name||' disable constraint '||constraint_name||';' from user_constraints;


SQL> alter table TABLE_NAME disable constraint CONSTRAINT_NAME;

SQL> alter table TABLE_NAME disable constraint CONSTRAINT_NAME cascade;


ENABLE:


select 'alter table '||owner||'.'||table_name||' enable constraint '||constraint_name||';' from user_constraints;

SQL> alter table TABLE_NAME enable constraint CONSTRAINT_NAME;

How to enable compression on table.

 Enable compression on table:

===================

Basic compression :

ALTER TABLE table_name  move COMPRESS ;

Advanced compression :

alter table table_name move ROW STORE COMPRESS ADVANCED;



Please check other posts for compression on partition table.

Script to check long running query

Long running query from database:


set pages 500
col sid for 9999
set lines 200
col MESSAGE for a85
col username format a15
select sid,serial#,inst_id,username,time_remaining,opname,ELAPSED_SECONDS/60 "Minutes elapsed",time_remaining/60 "Minutes remaining" from gv$session_longops where time_remaining>0;

Script to check archive generation per month

 Archive generation per month:

===========================


select to_char(FIRST_TIME,'YYYY') YEAR,to_char(FIRST_TIME,'MM') MONTH,to_char(FIRST_TIME,'DD') DAY,SUM(BLOCKS*BLOCK_SIZE)/1024/1024/1024,COUNT(1) from v$archived_log
where THREAD# = 1
and dest_id = 1
group by to_char(FIRST_TIME,'YYYY') ,to_char(FIRST_TIME,'MM') ,to_char(FIRST_TIME,'DD')
order by DAY
/

Common Oracle Clusterware crsctl commands

  Oracle Clusterware crsctl commands: # Check cluster status crsctl check crs crsctl check cluster # Cluster resources crsctl status reso...