Skip to content

Instantly share code, notes, and snippets.

@dotmaik1
dotmaik1 / lists unusable indexes.sql
Last active October 7, 2016 18:11
indexes: lists unusable indexes
select owner, index_name from dba_indexes where status='UNUSABLE';
@dotmaik1
dotmaik1 / rman: backup a database in NOARCHIVELOG.sql
Created October 7, 2016 17:28
backup a database in NOARCHIVELOG
To backup a database in NOARCHIVELOG mode you have to shutdown it first,
open in mount mode and only then you can start your backup process. 
[oracle@localhost ~]$ rman target /
Recovery Manager: Release 11.2.0.2.0 - Production on Thu Jan 21 11:44:08 2016
@dotmaik1
dotmaik1 / rman: arc_INST_hostname.sh
Created October 7, 2016 17:25
Simple backup archives script
#!/usr/bin/ksh
FECHA=$(date +"%d%m%y%H%M")
hostname=`hostname`
export ORACLE_HOME=/optware/oracle/11.2.0.4/db_1
export ORACLE_SID=ORAC256
export PATH=$ORACLE_HOME/bin:$PATH:.:$ORACLE_HOME/OPatch
export ruta=/optware/oracle/dbascripts/backups/logs
export rutafs=/u05/oradata/ORAC256/RMAN_BACKUP
rm -f ${rutafs}/*.arc
rm -f ${ruta}/ReportBKP_${ORACLE_SID}.log
CREATE DATABASE mynewdb
USER SYS IDENTIFIED BY sys_password
USER SYSTEM IDENTIFIED BY system_password
LOGFILE GROUP 1 ('/u01/logs/my/redo01a.log','/u02/logs/my/redo01b.log') SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/logs/my/redo02a.log','/u02/logs/my/redo02b.log') SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/logs/my/redo03a.log','/u02/logs/my/redo03b.log') SIZE 100M BLOCKSIZE 512
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1024
@dotmaik1
dotmaik1 / goldengate: monitoreo general Golden Gate.sql
Last active October 7, 2016 17:34
monitoreo general Golden Gate
e-----------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------
GGSCI (jagibmxdbu1n1) 1> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
@dotmaik1
dotmaik1 / dblinks structure.sql
Last active October 6, 2016 17:30
ddl gathering oracle
@dotmaik1
dotmaik1 / adrci: adrci commands
Created October 6, 2016 17:21
adrci commands
set base /u01/app/oracle
show home
show alert
show alert -p "message_text like "%incident%"'
show alert -p "message_text like "%ORA%"'
purge -age 43200 --purga diagnostic information de hace un mes
show problem
show incident
show incident -mode detail -p "incident_id=72697"
DECLARE
l_object_id NUMBER;
BEGIN
-- Create a segment advisor task for the SCOTT.EMP table.
DBMS_ADVISOR.create_task (
advisor_name => 'Segment Advisor',
task_name => 'EMP_SEGMENT_ADVISOR',
task_desc => 'Segment Advisor For EMP');
DBMS_ADVISOR.create_object (
@dotmaik1
dotmaik1 / advisors: Segment advisor per schema.sql
Created October 6, 2016 17:20
Segment advisor per schema
DECLARE
l_object_id NUMBER;
BEGIN
-- Create a segment advisor task for the PAPERLESS tablespace.
DBMS_ADVISOR.create_task (
advisor_name => 'Segment Advisor',
task_name => 'PAPERLESS_SEGMENT_ADVISOR',
task_desc => 'Segment Advisor For PAPERLESS');
DBMS_ADVISOR.create_object (
@dotmaik1
dotmaik1 / advisors: segment_advisor.sql
Created October 6, 2016 17:19
segment_advisor.sql
-- -----------------------------------------------------------------------------------
-- File Name : https://oracle-base.com/dba/10g/segment_advisor.sql
-- Author : Tim Hall
-- Description : Displays segment advice for the specified segment.
-- Requirements : Access to the DBMS_ADVISOR package.
-- Call Syntax : Object-type = "tablespace":
-- @segment_advisor.sql tablespace (tablespace-name) null
-- Object-type = "table" or "index":
-- @segment_advisor.sql (object-type) (object-owner) (object-name)
-- Last Modified: 08-APR-2005