Skip to content

Instantly share code, notes, and snippets.

SELECT LPAD(' ', (level-1)*2, ' ') || NVL(s.username, '(oracle)') AS username,
s.osuser,
s.sid,
s.serial#,
s.lockwait,
s.status,
s.module,
s.machine,
s.program,
s.event,
@kotlas92
kotlas92 / Oracle shrink datafiles
Last active April 29, 2019 11:34
Oracle shrink datafiles
-- https://blog.dbi-services.com/resize-your-oracle-datafiles-down-to-the-minimum-without-ora-03297/
set linesize 1000 pagesize 0 feedback off trimspool on
with
hwm as (
-- get highest block id from each datafiles ( from x$ktfbue as we don't need all joins from dba_extents )
select /*+ materialize */ ktfbuesegtsn ts#,ktfbuefno relative_fno,max(ktfbuebno+ktfbueblks-1) hwm_blocks
from sys.x$ktfbue group by ktfbuefno,ktfbuesegtsn
),
@kotlas92
kotlas92 / Oracle flush execution plan
Last active April 29, 2019 11:34
Oracle flush execution plan
SQL> select ADDRESS, HASH_VALUE from V$SQLAREA where SQL_ID like '7yc%';
ADDRESS HASH_VALUE
---------------- ----------
000000085FD77CF0 808321886
SQL> exec DBMS_SHARED_POOL.PURGE ('000000085FD77CF0, 808321886', 'C');
PL/SQL procedure successfully completed.

Keybase proof

I hereby claim:

  • I am kotlas92 on github.
  • I am kotlas92 (https://keybase.io/kotlas92) on keybase.
  • I have a public key ASCmGVaITtlugSElAOqYJ7McNyQw8TFjpyqI_D8ABE3e-wo

To claim this, I am signing this object: