The following script help to find, how often the redo logs were switched.
It calculates the number by date and by hour.
JavaScript: Soundex implementation
There is a special algorithm for comparision strings, which sound similar (Soundex).
Here is JavaScript Soundex implementation:
function soundex ( s_src )
{
var s_rez = "0000" ;
var new_code, prev, idx
a_codes = { "bfpv": 1, "cgjkqsxz":2, "dt": 3, "l": 4, "mn": 5, "r": 6 };
s_src = s_src.toLowerCase().replace(/ /g,"")
if ( s_src.length < 1) {
return(s_rez);
}
s_rez = s_src.substr(0,1);
prev = "0";
for ( idx = 1 ; idx < s_src.length ; idx++) {
new_code = "0";
cur_char = s_src.substr(idx,1)
for (s_code in a_codes)
if (s_code.indexOf(cur_char) >= 0)
{ new_code = a_codes[ s_code ] ; break ; }
if (new_code != prev && new_code != "0" ) {
s_rez += new_code;
}
prev = new_code;
}
s_rez = s_rez + "0000"
return s_rez.substr(0,4);
}
Oracle: usage of the tablespaces
set pagesize 10000
set COLSEP '|'
set VERIFY off
set serveroutput on size 1000000
BREAK ON report
column tablespace_name format a30 heading 'TABLESPACE'
column sizegb format 9999999999D9 heading 'SIZE-Gb'
column usedproc format 999D99 heading 'USED-%'
column status format a10 heading 'STATUS'
COMPUTE sum LABEL 'Total size:' of sizegb ON report
SELECT b.tablespace_name ,
b.bytes/1024/1024/1024 as sizegb ,
NVL(100-((a.bytes/b.bytes)*100), 100) usedproc,
replace(c.status,' ','_') status
FROM
( select tablespace_name,
sum(bytes) bytes
from dba_free_space
group by tablespace_name
) a ,
( select tablespace_name,
sum(bytes) bytes
from dba_data_files
group by tablespace_name
) b ,
dba_tablespaces c
WHERE b.tablespace_name = a.tablespace_name (+)
AND b.tablespace_name = c.tablespace_name
union
select f.TABLESPACE_NAME,
f.TOTAL_MB/1024 sizegb,
nvl( (u.USED_MB/f.TOTAL_MB)*100, 0 ) usedproc,
'TEMPORARY' status
from
(
select f1.TABLESPACE_NAME,sum( f1.BYTES/1024/1024 ) TOTAL_MB
from (
select TABLESPACE_NAME,BYTES
from dba_temp_files
union all
select TABLESPACE_NAME,BYTES
from dba_data_files
where TABLESPACE_NAME in (
select TABLESPACE_NAME
from dba_tablespaces
where CONTENTS='TEMPORARY'
)
) f1
group by f1.TABLESPACE_NAME
) f,
(
select u1.TABLESPACE,
sum(u1.blocks) * max((select value from v$parameter where name='db_block_size')/1024/1024) USED_MB
from v$sort_usage u1
group by u1.TABLESPACE
) u
where f.TABLESPACE_NAME = u.tablespace (+)
ORDER BY 1;
AppleScript: rotate mov file in QuickTime Pro
Some kind of life hack: it’s very easy to make mov file with digital camera, rotating it 90 degrees. However, it’s not so easy to convert the result file to the ‘visible’ form.
QuickTime Pro(the native product from Apple) could do this, and I found the AppleScript script, which could make it even more easy.
tell application "QuickTime Player"
set m to (get movie 1)
rotate m by -90
save self contained m in (choose file name with prompt "save self contained movie")
end tell
The script is mentioned here
Oracle: plan of the running query
col object_name for a40
select operation,
options,
object_name,
partition_id
from v$sql_plan
where address in
( select sql_address from v$session where sid = &sid.)
order by id;
Oracle: using DBMS_METADATA for getting table structure
set long 5000
select dbms_metadata.get_ddl('TABLE','EMP','SCOTT')
from dual;
Some other values of the type field for dbms_metadata.get_ddl function:
(See also “Oracle® Database PL/SQL Packages and Types Reference“)
Oracle: using substitution variables in sqlplus
Get the value:
ACCEPT my_password CHAR PROMPT 'Password: ' HIDE
ACCEPT birthday DATE FORMAT 'dd/mm/yyyy' DEFAULT '01/01/1950' PROMPT 'Enter birthday date: '
Declaring the variable
DEFINE the_answer = 42
Undefine the variable
UNDEFINE the_answer
How to remember the result of the query
column the_date new_value the_rundate noprint;
select to_char(sysdate, 'DDMMYYYY_HH24MI') the_date from dual;
select '&the_rundate' from dual ;
Save the variables to the file
store set myvars.txt create
store set myvars.txt replace
store set myvars.txt append
Assign several values to the variable
DEFINE my_list = " 'the Life', 'the Universe', 'and Everything'"
select *
from Book
where answer in ( &my_list );
Oracle: disable all constraints referencing the table
begin
for cur in (select fk.owner, fk.constraint_name , fk.table_name
from all_constraints fk, all_constraints pk
where fk.CONSTRAINT_TYPE = 'R' and
pk.owner = '&which_owner' and
fk.R_CONSTRAINT_NAME = pk.CONSTRAINT_NAME
and pk.TABLE_NAME = '&which_table'
) loop
execute immediate 'ALTER TABLE '||cur.owner||'.'||cur.table_name||
' MODIFY CONSTRAINT '||cur.constraint_name||' DISABLE';
end loop;
end;
Oracle: info about the corrupted block
select * from dba_extents
where file_id = &file_id
and &block_id between block_id and block_id + blocks - 1;
Oracle: using recycling bin
Information about the objects in recycle bin:
select object_name,
original_name, type,
can_undrop , can_purge ,
droptime
from recyclebin
or
show recyclebin
Restore
flashback table mytable to before drop;
Clear recycle bin
purge recyclebin;