Can't find what you're looking for? Use of one of the search websites below …

HomeoracleArchive by category "scripts"

Category Archives: scripts

dbverify in nohup

Suffering from corruption in your database, it is nearly just as challenging as in real life…

The other day we suffered from a curruption in a 500+ Gigabyte database, as a sequentual dberify would take about 16+ hours I wrote this one below which starts the dbv’s in nohup in parallel. My dbv finished within the hour, system performance will drop though;)

[SYSTEM@DB01.REMIDIAN.COM]
SQL> l
  1  select
  2  'nohup dbv' ||
  3   ' file=' || file_name ||
  4   ' blocksize=4096' ||
  5   ' logfile=' || file_id || '_' || substr( file_name, instr(file_name,'/',-1) +1) || '.log &'
  6  from
  7* dba_data_files
[SYSTEM@DB01.REMIDIAN.COM]
SQL> /
 
'NOHUPDBVFILE='||FILE_NAME||'BLOCKSIZE=4096LOGFILE='||FILE_ID||'_'||SUBSTR(FILE_NAME,INSTR(FILE_NAME,'/',-1)+1)||'.LOG&'
------------------------------------------------------------------------------------------------------------------------
nohup dbv file=C:\ORACLE\ORADATA\DB01\DB01\USERS01.DBF blocksize=4096 logfile=4_C:\ORACLE\ORADATA\DB01\DB01\USERS01.DBF.log &
nohup dbv file=C:\ORACLE\ORADATA\DB01\DB01\SYSAUX01.DBF blocksize=4096 logfile=3_C:\ORACLE\ORADATA\DB01\DB01\SYSAUX01.DBF.log &
nohup dbv file=C:\ORACLE\ORADATA\DB01\DB01\UNDOTBS01.DBF blocksize=4096 logfile=2_C:\ORACLE\ORADATA\DB01\DB01\UNDOTBS01.DBF.log &
nohup dbv file=C:\ORACLE\ORADATA\DB01\DB01\SYSTEM01.DBF blocksize=4096 logfile=1_C:\ORACLE\ORADATA\DB01\DB01\SYSTEM01.DBF.log &
nohup dbv file=C:\ORACLE\ORADATA\DB01\DB01\EXAMPLE01.DBF blocksize=4096 logfile=5_C:\ORACLE\ORADATA\DB01\DB01\EXAMPLE01.DBF.log &
nohup dbv file=C:\ORACLE\ORADATA\DB01\DB01\P1PERG001.DBF blocksize=4096 logfile=7_C:\ORACLE\ORADATA\DB01\DB01\P1PERG001.DBF.log &
nohup dbv file=C:\ORACLE\ORADATA\DB01\DB01\P1PERG002.DBF blocksize=4096 logfile=8_C:\ORACLE\ORADATA\DB01\DB01\P1PERG002.DBF.log &

delete large number of records with intermediate commits

Have to delete a large number of records and running out of undo tablespace ‘ORA-30036: unable to extend segment by 8 in undo tablespace ‘UNDO’? Script below does a delete with intermediate commits ever ‘x’ records.

declare
 
  -- commit every 'i_commit' rows
  i_commit   pls_integer := 1000;
 
  -- row counter, 'i_rowcount' rows deleted
  i_rowcount pls_integer := 0;
 
begin
 
  -- define 'infinite' loop
  loop
 
    -- delete 'i_commit' rows
    delete from obj
    where rownum <= i_commit;
 
    i_rowcount := i_rowcount + sql%rowcount;
 
    -- now it's time to exit the loop
    if sql%rowcount = 0 then
       commit;
       exit;
    end if;
 
    commit;
 
  end