Friday, 4 November 2011
Wylistowanie userów i ich dropowanie
select 'drop user ' || username || ' cascade; ' FROM DBA_USERS;
odświeżenie statystyk na bazie danych oracle
dbms_utility.analyze_schema(schema=>'INSIS',method=>'ESTIMATE',estimate_percent=>5);
Odblokowanie statystyk na tabelach oracle'a
select 'exec DBMS_STATS.UNLOCK_TABLE_STATS(''' || owner ||''' ,''' || table_name || '''); ' from dba_tab_statistics where stattype_locked is not null and owner not in ('SYS','SYSTEM');
Czyszczenie REDO logów
run {
crosscheck archivelog all;
delete expired archivelog all;
}
run {
BACKUP ARCHIVELOG ALL;
DELETE COPY OF ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-1';
}
run {
DELETE NOPROMPT ARCHIVELOG ALL COMPLETED BEFORE
'sysdate-10/24'; ---kasuje wszystkie z przed 13h
}
crosscheck archivelog all;
delete expired archivelog all;
}
run {
BACKUP ARCHIVELOG ALL;
DELETE COPY OF ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-1';
}
run {
DELETE NOPROMPT ARCHIVELOG ALL COMPLETED BEFORE
'sysdate-10/24'; ---kasuje wszystkie z przed 13h
}
Oznaczenie w rmanie przeterminowanych redo logów na sysdate -1
set serveroutput on;
spool /tmp/output_del_logs.txt
declare CURSOR cur IS
SELECT a.name
FROM v$asm_alias a, v$asm_file b
where a.group_number = b.group_number
and b.creation_date < sysdate-1
and a.file_number = b.file_number
and b.type='ARCHIVELOG'
and a.name like '%.arc'
order by a.name;
sqlstr VARCHAR2(250);
BEGIN
FOR cur_rec IN cur
LOOP
sqlstr := 'alter diskgroup ASM_BACKUP drop file ''+ASM_BACKUP/DB1/' || cur_rec.name || '''';
DBMS_OUTPUT.PUT_LINE(sqlstr);
EXECUTE IMMEDIATE sqlstr;
END LOOP;
END;
/
spool off;
exit
spool /tmp/output_del_logs.txt
declare CURSOR cur IS
SELECT a.name
FROM v$asm_alias a, v$asm_file b
where a.group_number = b.group_number
and b.creation_date < sysdate-1
and a.file_number = b.file_number
and b.type='ARCHIVELOG'
and a.name like '%.arc'
order by a.name;
sqlstr VARCHAR2(250);
BEGIN
FOR cur_rec IN cur
LOOP
sqlstr := 'alter diskgroup ASM_BACKUP drop file ''+ASM_BACKUP/DB1/' || cur_rec.name || '''';
DBMS_OUTPUT.PUT_LINE(sqlstr);
EXECUTE IMMEDIATE sqlstr;
END LOOP;
END;
/
spool off;
exit
Zamiana ciągu znaków w plikach o podanej nazwie
Aby zmienić ciąg znakow w plikach o nazwie name*, można użyć poniższego polecenia.
find . -name 'name*' -exec sed -i 's/first/second/g' '{}' \;
Można dodać opcję wyszukiwania w plikach
find . -type f -name '*.xdo' -exec sed -i 's/first/second/' '{}' \;
find . -name 'name*' -exec sed -i 's/first/second/g' '{}' \;
Można dodać opcję wyszukiwania w plikach
find . -type f -name '*.xdo' -exec sed -i 's/first/second/' '{}' \;
Subscribe to:
Posts (Atom)