You are on page 1of 42

SQL> select 'alter user '||USERNAME||' default tablespace USERS;' from dba_users

where DEFAULT_TABLESPACE='SYSTEM';

'ALTERUSER'||USERNAME||'DEFAULTTABLESPACEUSERS;'
-------------------------------------------------------------------
alter user SYS default tablespace USERS;
alter user SYSTEM default tablespace USERS;
alter user DBSNMP default tablespace USERS;

W-INCFLS-GDO-MNL-DB
itodba password: usp12f:i
oracle@[vfifsd1]/opt/oracle > . ./vfifsd1env
set ORACLE_SID=<instance name>
set local=<instance_name>

DBSPI
-----------------------
dbspicfg -e --->for checking stats
dbspicol off / dbspicol on <w or w/o instance>
mv /var/opt/OV/dbspi/dbmon.lock.5m /var/opt/OV/dbspi/dbmon.lock.5m08092011
------->renaming locks

dbspicam -v -d -f -p for sql


dbspicao -v -d -f -p for oracle

DBSPI STATUS CHECKING


==========================

sample:
dbspiadm verify -nw VCX0001R01

command:
dbspiadm conncheck -nw <instance name>

DBSPI CONFIG
====================
dbspicao -v -d -f -p

DBSPI ON/OFF
==========================

dbspicol ON < instance >


dbspicol OFF < instance>

DBSPI CHECKING
-----------------------------------------------------------------------------------
--
/var/opt/OV/bin/instrumentation/dbspicam -m 3234 -r 1 -i VCXSQLPC01\SQLINSTANCE01
- m for metric (e.g. DBSPI9)
- r di ko alam
- lagay mo lng
- i for instance

ARCHIVELOG SCRIPTS ( AUTOBACKUP/AUTO FREEUP)


-----------------------------------------------------------------------------------
--
report-zeus[oracle]/w99/oradbf/FBOPERP/archivelog # -->>nohup
/outils/archivelogsbackupFBOPERP.sh &
nohup
/outils/archivelogsbackupFBERPP.sh &

-------

report-zeus[oracle]/t99/oradbf/BIV2/archivelogs # -->>nohup
/outils/archivelogsbackupBIV2.sh & //////////////// ARCHIVE LOG SCRIPT (Start sa
nohup!)
admin-zeus: -->>nohup
/outils/archivelogsbackupFBSDESKP.sh &

FOR REPORT-ZEUS CHECKING


====================================================================
while true
do
echo ======================ARCHIVE BACKUP=========================
ps -ef| grep arch
echo
echo ========================HOT BACKUP===========================
ps -ef| grep hot
echo
echo ======================FS UTILIZATION=========================
df -k /w99
echo
df -k /t99
sleep 5
clear
done

FOR ADMIN-ZEUS CHECKING


====================================================================
while true
do
echo ======================ARCHIVE BACKUP=========================
ps -ef| grep arch
echo
echo ========================HOT BACKUP===========================
ps -ef| grep hot
echo
echo ======================FS UTILIZATION=========================
df -k /t99
sleep 5
clear
done
CHECK DB VERSION AND DATA INSTALLED
-----------------------------------------------------------------------------------
--

Date of Install: select CREATED from v$database;


DB Edition: select * from v$version;

SHARED POOL CHECKING


-----------------------------------------------------------------------------------
--

select a.pool, sum(a.bytes/1048576), b.Free_Memory from v$sgastat a, (select


sum(bytes/1048576) AS Free_Memory, pool AS Pool_name
from v$sgastat where name ='free memory' group by pool) b where a.pool=b.Pool_name
group by a.pool, b.Free_Memory;

SHAREDPOOL FLUSH
-----------------------------------------------------------------------------------
--
alter system flush shared_pool;

==To show the available shared pool on the database==


select name, pool, bytes/1024/1024 from v$sgastat where name='free memory';

==Do this 3 times (flusing the shared pool)==


alter system flush shared_pool;

CHECK ORACLE BACKGROUND


-----------------------------------------------------------------------------------
--
show parameter back

SHORTCUTS
-----------------------------------------------------------------------------------
--

goto conversation

cd $DBA

DB STATUS
-----------------------------------------------------------------------------------
--

set linesize 160


col host_name for a20
col open_mode for a20
col Current_Time for a20
col STARTUP_TIME for a20
select name, open_mode, host_name,
to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS') AS Current_Time,
to_char(startup_time, 'DD-MON-YYYY HH24:MI:SS') AS STARTUP_TIME
from v$database, v$instance, dual;

TABLE SPACE (HEALTH CHECK)


-----------------------------------------------------------------------------------
--

col tablespace_name for a40


select b.tablespace_name, b.total "Mb Total",
sum( a.bytes/(1024 * 1024)) "Mb Free",
sum( a.bytes/(1024 * 1024))/b.total*100 "%Free"
from dba_free_space a,
(select tablespace_name, sum(bytes/1024/1024) total
from dba_data_files group by tablespace_name) b
where a.tablespace_name(+)=b.tablespace_name
group by b.tablespace_name, b.total order by 4;

TABLE SPACE (HEALTH CHECK)-SPECIFIC


-----------------------------------------------------------------------------------
--

col tablespace_name for a40


select b.tablespace_name, b.total "Mb Total",
sum( a.bytes/(1024 * 1024)) "Mb Free",
sum( a.bytes/(1024 * 1024))/b.total*100 "%Free"
from dba_free_space a,
(select tablespace_name, sum(bytes/1024/1024) total
from dba_data_files group by tablespace_name) b
where a.tablespace_name(+)=b.tablespace_name
and b.tablespace_name like '%ASWPIWIK_DAT_TAB%'
group by b.tablespace_name, b.total order by 4;

SOITEC
----------------------------
dbspicao -m6 -r1 -i FBERPP

DATA FILE (FREE SPACE)


-----------------------------------------------------------------------------------
--

set linesize 140


col file_name for a60
select file_name, bytes/(1024 * 1024), autoextensible, MAXBYTES/(1024 * 1024) from
dba_data_files where tablespace_name ='ASWPIWIK_DAT_TAB';
set linesize 140
col file_name for a60
select file_name, bytes/(1024 * 1024), autoextensible, MAXBYTES/(1024 * 1024) from
dba_data_files;

DATA FILE USAGE


----------------
SELECT SUBSTR (df.NAME, 1, 40) file_name, df.bytes / 1024 / 1024 allocated_mb,
((df.bytes / 1024 / 1024) - NVL (SUM (dfs.bytes) / 1024 / 1024, 0))
used_mb,
NVL (SUM (dfs.bytes) / 1024 / 1024, 0) free_space_mb
FROM v$datafile df, dba_free_space dfs
WHERE df.file# = dfs.file_id(+)
GROUP BY dfs.file_id, df.NAME, df.file#, df.bytes
ORDER BY file_name;

DATA FILE TABITHA (FREE SPACE)


-----------------------------------------------------------------------------------
--

SELECT NAME, TOTAL_MB, FREE_MB FROM V$ASM_DISKGROUP;

SELECT FILE_TYPE "Type",


PERCENT_SPACE_USED "% Used",
PERCENT_SPACE_RECLAIMABLE "% Reclaim",
NUMBER_OF_FILES "# Files"
FROM V$FLASH_RECOVERY_AREA_USAGE;

SELECT
ROUND((A.SPACE_LIMIT / 1024 / 1024 / 1024), 2) AS FLASH_IN_GB,
ROUND((A.SPACE_USED / 1024 / 1024 / 1024), 2) AS FLASH_USED_IN_GB,
ROUND((A.SPACE_RECLAIMABLE / 1024 / 1024 / 1024), 2) AS FLASH_RECLAIMABLE_GB,
SUM(B.PERCENT_SPACE_USED) AS PERCENT_OF_SPACE_USED
FROM
V$RECOVERY_FILE_DEST A,
V$FLASH_RECOVERY_AREA_USAGE B
GROUP BY
SPACE_LIMIT,
SPACE_USED ,
SPACE_RECLAIMABLE;

SQL> SHOW PARAMETER DB_RECOVERY_FILE_DEST

NAME TYPE VALUE


------------------------ ----------- ------
db_recovery_file_dest string /opt/app/oracle/flash_recovery_area
db_recovery_file_dest_size big integer 2G

TO INCREASE FRA SIZE:


alter system set db_recovery_file_dest_size=20g scope=both;

TEMP FILE(FREE SPACE)


-----------------------------------------------------------------------------------
--

set linesize 140


select file_name, bytes/1024/1024, autoextensible from dba_temp_files where
tablespace_name ='MSQP_TEMP';

select TABLESPACE_NAME, BYTES_USED/1024/1024, BYTES_FREE/1024/1024 from


V$TEMP_SPACE_HEADER;

select TABLESPACE_NAME, BYTES_USED/1024/1024, BYTES_FREE/1024/1024 from


V$TEMP_SPACE_HEADER where tablespace_name ='VCENTER_TEMP';

SELECT A.tablespace_name tablespace, D.mb_total,


SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_used,
D.mb_total - SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_free
FROM v$sort_segment A,
(
SELECT B.name, C.block_size, SUM (C.bytes) / 1024 / 1024 mb_total
FROM v$tablespace B, v$tempfile C
WHERE B.ts#= C.ts#
GROUP BY B.name, C.block_size
) D
WHERE A.tablespace_name = D.name
GROUP by A.tablespace_name, D.mb_total;

RESIZING TEMP
-----------------------------------------------------------------------------------
--
alter database tempfile '/u02/P608/oradata1/VCENTER_TEMP01.dbf' resize 3300M

DATA FILE CONTENT


-----------------------------------------------------------------------------------
--

select tablespace_name, contents from dba_tablespaces


where tablespace_name='SYSAUX';

DATA FILE ALTERATION


-----------------------------------------------------------------------------------
--

alter database datafile '/db/vfpos01/data/vfpos01/dm_idx_01.dbf' resize 7800M;

# dbspicao -m6 -r1 -i udbprod

Report For Database udbprod

Tue May 8 07:36:46 2012


Metric TblSpaceFreePctCnt (0006)

DATA FILE FREE FILE SYSTEM


TABLESPACE_NAME SPACE (MB) SPACE (MB) SPACE (MB)
PERCENT FREE AUTOEXTEND
---------------------------------- ---------------- ----------- ------------
------------ ----------
UDB_LAR_DATA 230824.00 100.00 35588.39
13.40 YES
UDB_LAR_INDEX 93056.00 160.00 35588.39
27.79 YES
UDB_MED_DATA 3072.00 160.00 1024.00
28.91 YES
UDB_MED_INDEX 6471.00 640.00 3529.00
41.69 YES
UDB_INDEX 1024.00 584.19 31743.98
98.66 YES
SYSAUX 500.00 297.50 32267.98
99.38 YES
SYSTEM 400.00 208.88 32367.98
99.42 YES
UDB_DATA 1024.00 874.12 31743.98
99.54 YES
UNDOTBS 4084.00 4061.50 1036.00
99.56 YES
USERS 10.00 9.94 32757.98
100.00 YES

TABLESPACE_NAME: Name of the tablespace


DATA FILE
SPACE (MB): Total amount of allocated disk space in megabytes
FREE
SPACE (MB): Total amount of free space from dba_free_space in megabytes
FILE SYSTEM
SPACE (MB): Total amount of file system space available (in multiples of DB
block size) if AUTOEXTENT is enabled
PERCENT FREE: Percentage of free space (including file system space if
AUTOEXTENT is enabled)
AUTOEXTEND: Whether the tablespace has at least one datafile where AUTOEXTEND
is enabled
Value of YNS indicates unsupported RAW partition with AUTOEXTEND
enabled
Value of ERR indicates an error occured while getting file system
information

DATA FILE CREATION


-----------------------------------------------------------------------------------
--

alter tablespace GPRS_DATA_1011 add datafile


'/db/vftranp1/cs_data_2/GPRS_DATA/vftranp1_gprs_data_1011_11.dbf' size 5000M;

alter tablespace UNDOTBS1 add datafile '/db/icprd_db2/dd_idx/' size ung gusto mong
size
Alter tablespace<tablespacename to be extend> add datafile '<given
directory><filename>' size <max 30000M>

TEMP FILE CREATION


-----------------------------------------------------------------------------------
--

ALTER TABLESPACE SHOP2_TEMP ADD TEMPFILE


'/u02/E625/oradata1/AMDBSMPROFILE_DAT_OBJ01.dbf' SIZE 11200M;

DEFAULT TEMPORARY TABLESPACE FOR A DATABASE


-----------------------------------------------------------------------------------
--

SELECT * FROM DATABASE_PROPERTIES where PROPERTY_NAME='DEFAULT_TEMP_TABLESPACE';

FREE PSACE TEMPORARY TABLESPACE


-----------------------------------------------------------------------------------
--

select TABLESPACE_NAME, BYTES_USED, BYTES_FREE from V$TEMP_SPACE_HEADER;

APPS THAT HAS GREATER SPACE OCCUPIED


-----------------------------------------------------------------------------------
--

SET LINES 170 PAGES 5000


COL TOTAL_MB FOR 999,999,990.99
COL OWNER FOR A15
COL SEGMENT_TYPE FOR A15
COL TABLESPACE_NAME FOR A15
COL SEGMENT_NAME FOR A30
SELECT OWNER, TABLESPACE_NAME, SEGMENT_TYPE, SEGMENT_NAME,
ROUND((sum(BYTES)/1024/1024), 2) TOTAL_MB
FROM DBA_SEGMENTS
where owner not in ('SYS', 'SYSTEM', 'OUTLN')
and SEGMENT_TYPE = 'TABLE'
GROUP BY OWNER, TABLESPACE_NAME, SEGMENT_TYPE, SEGMENT_NAME
ORDER BY TOTAL_MB desc, owner asc;

QUERY DURATION - MAX QUERYLYN


-----------------------------------------------------------------------------------
--

select v.name||:"SYS_B_00"||
lpad(to_char(sysdate,:"SYS_B_01"),:"SYS_B_02",:"SYS_B_03")||:"SYS_B_04"||
a.tbs1||:"SYS_B_05"||a.dtftotal||:"SYS_B_06"||b.datasize||:"SYS_B_07"||c.dtfcount
from
(select tablespace_name tbs1, sum(bytes)/:"SYS_B_08"/:"SYS_B_09" dtftotal
from dba_data_files group by tablespace_name) a,
(select tablespace_name tbs2, sum(bytes)/:"SYS_B_10"/:"SYS_B_11" datasize
from dba_extents group by tablespace_name) b,
(select tablespace_name tbs3, count(file_id) dtfcount
from dba_data_files group by tablespace_name) c,
v$database v
where a.tbs1=b.tbs2 and b.tbs2=c.tbs3

col maxquerylen for a90


set linesize 140
select maxquerylen,
to_char(begin_time, 'DD-MON-YYYY HH24:MI:SS'),
to_char(end_time, 'DD-MON-YYYY HH24:MI:SS')
from v$undostat where SSOLDERRCNT <>0;

col maxquerylen for a90


set linesize 140
select maxquerylen, begin_time, end_time, UNXPSTEALCNT, NOSPACEERRCNT from
v$undostat where SSOLDERRCNT <>0;
#to_char(begin_time, 'DD-MON-YYYY HH:MI S'),
#to_char(end_time, 'DD-MON-YYYY HH:MI S')
from v$undostat where SSOLDERRCNT <>0;

select SSOLDERRCNT, BEGIN_TIME, END_TIME, TXNCOUNT from v$undostat where


SSOLDERRCNT <> 0;
--------------------------------------------------------------------
Location of the log files.

SQL>show parameter background


SQL>!
oracle@[vfsoap1]/opt/oracle > cd /db/vfsoap1/dba/bdump

for sun - solaris


/usr/local/bin/sudo su - oracle
---------------------------------------------------------------------
for soitec
connect to oracle
su - oraprod
---------------------------------------------------------------------
==UNDO Retention==
col file_name for a60
set linesize 140
SELECT d.undo_size/(1024*1024) "ACTUAL UNDO SIZE [MByte]",
SUBSTR(e.value,1,25) "UNDO RETENTION [Sec]",
ROUND((d.undo_size / (to_number(f.value) *
g.undo_block_per_sec))) "OPTIMAL UNDO RETENTION [Sec]"
FROM (SELECT SUM(a.bytes) undo_size
FROM v$datafile a,
v$tablespace b,
dba_tablespaces c
WHERE c.contents = 'UNDO'
AND c.status = 'ONLINE'
AND b.name = c.tablespace_name
AND a.ts# = b.ts#
) d,
v$parameter e,
v$parameter f,
(
SELECT MAX(undoblks/((end_time-begin_time)*3600*24))
undo_block_per_sec
FROM v$undostat
) g
WHERE e.name = 'undo_retention'
AND f.name = 'db_block_size';

show parameter undo_retention

select max(maxquerylen) from v$undostat;

select SSOLDERRCNT, BEGIN_TIME, END_TIME, TXNCOUNT from v$undostat where


SSOLDERRCNT <> 0;

select maxquerylen,
to_char(begin_time, 'DD-MON-YYYY HH24:MI:SS'),
to_char(end_time, 'DD-MON-YYYY HH24:MI:SS')
from v$undostat where maxquerylen=(
select max(maxquerylen) from v$undostat);

-Reviewed the alert log


ORA-01555 caused by SQL statement below (Query Duration=1277343111 sec, SCN:
0x070c.d34a77bf):
Thu Jun 24 13:31:51 2010
select v.name||:"SYS_B_00"||
lpad(to_char(sysdate,:"SYS_B_01"),:"SYS_B_02",:"SYS_B_03")||:"SYS_B_04"||
a.tbs1||:"SYS_B_05"||a.dtftotal||:"SYS_B_06"||b.datasize||:"SYS_B_07"||c.dtfcount
from
(select tablespace_name tbs1, sum(bytes)/:"SYS_B_08"/:"SYS_B_09" dtftotal
from dba_data_files group by tablespace_name) a,
(select tablespace_name tbs2, sum(bytes)/:"SYS_B_10"/:"SYS_B_11" datasize
from dba_extents group by tablespace_name) b,
(select tablespace_name tbs3, count(file_id) dtfcount
from dba_data_files group by tablespace_name
Thu Jun 24 13:50:10 2010
Beginning log switch checkpoint up to RBA [0x159cf.2.10], SCN: 0x070c.d34e1d7a

LONG-RUNNING QUERY
====================================================
COLUMN percent FORMAT 999.99

SELECT sid, to_char(start_time,'hh24:mi:ss') stime,


message,( sofar/totalwork)* 100 percent
FROM v$session_longops
WHERE sofar/totalwork < 1
/

ORA ERROR DIRECTORY


=============================================================================
iudb719:/u02/P639/app/oracle/admin/bdump$ oerr ora 60
00060, 00000, "deadlock detected while waiting for resource"
// *Cause: Transactions deadlocked one another while waiting for resources.
// *Action: Look at the trace file to see the transactions and resources
// involved. Retry if necessary.

==============
select TABLESPACE_NAME, BYTES_USED, BYTES_FREE,
BYTES_FREE/(BYTES_FREE+BYTES_USED) * 100 as FREE from
V$TEMP_SPACE_HEADER;

==In Flight temp Usage==


SELECT b.tablespace, b.segfile#, b.segblk#, b.blocks, a.sid, a.serial#,
a.username, a.osuser, a.status
FROM v$session a,v$sort_usage b
WHERE a.saddr = b.session_addr ORDER BY b.tablespace, b.segfile#, b.segblk#,
b.blocks;

==oooooooooooooooooo==

sqlplus -s "/ as sysdba" << EOF


col instance_name new_value inst_name
select instance_name from v\$instance;
col alert new_value alert_log
select 'cat ' || value || '/alert_' || '&inst_name' || '.log' || ' | tail -3000' ||
' | egrep ' || '''' || 'Shutting|Starting|ORA-|Mon|Tue|Wed|Thu|Fri|Sat|Sun|Errors'
|| '''' alert
from v\$parameter where name='background_dump_dest';
host &alert_log;
EOF

================
alter database datafile '/db/vfcmsp1/temp/vfcmsp1_temp_01.dbf' AUTOEXTEND ON
MAXSIZE 1500M;
alter database tempfile '/db/vfcmsp1/temp/vfcmsp1_temp_01.dbf' AUTOEXTEND ON
MAXSIZE 1500M;

==Locking Transaction (Deadlock)==


set linesize 160
col SQL_TEXT for a60
col ORACLE_USERNAME for a14
col object_name for a15
select a.SESSION_ID, c.SQL_TEXT, a.ORACLE_USERNAME, d.object_name, d.object_type
from v$locked_object a, v$session b, v$sqlarea c, dba_objects d
where (a.session_id=b.sid and c.address=b.sql_address) and d.object_id=a.object_id;

==Tablespace that occupies the most space==


SET LINES 170 PAGES 5000
COL TOTAL_MB FOR 999,999,990.99
COL OWNER FOR A15
COL SEGMENT_TYPE FOR A15
COL TABLESPACE_NAME FOR A15
COL SEGMENT_NAME FOR A30
SELECT OWNER, TABLESPACE_NAME, SEGMENT_TYPE, SEGMENT_NAME,
ROUND((sum(BYTES)/1024/1024), 2) TOTAL_MB
FROM DBA_SEGMENTS
where owner not in ('SYS', 'SYSTEM', 'OUTLN')
and SEGMENT_TYPE = 'TABLE'
GROUP BY OWNER, TABLESPACE_NAME, SEGMENT_TYPE, SEGMENT_NAME
ORDER BY TOTAL_MB desc, owner asc;

==Archive location==
SQL>archive log list

==User and password==


[root@fbbf3pa] /home/root #dbspicao -r 1 -m 730 -i udbprod

==listener log==
tail -1000000 listener_vfifsp1.log |grep TNS-

==Unix command for the latest file in the FS==


ivdb1ldv:root$ find /tools -xdev -type f -mtime 0 -exec ls -l {} \; | sort -rnk 5|
head -100

==Unix command to sort for largest file==


find /db2instance/db2home/pmsinst -xdev -size +5000 -exec ls -lrt {} \; | sort -rnk
5 | head -50
find /tools -xdev -mtime -1 -exec ls -lrt {} \; | sort -rnk 5 | head -50
find /tools -xdev -type f -mtime -1 -exec ls -ld {} \; | sort -rnk 5 | head -15
find /tools -xdev -type f -size +30000 -exec ls -ltr {} \;

find /db2instance/db2home/ -name '*20101005.log' -exec ls -lrt {} \;

**==Unix command to REMOVE file==**


find . -name '*.log' -mtime +5 -exec rm -rf {} \; &
(*.log)(*.dmp)(*.aud)(*.trc)----(+5==#ofdays)

ls -l | grep "Sep 13" | awk ' {print $9}' | xargs rm

==Unix command to know who log in the server==


last

==Unix command to look for a file==


find / -type f -name 'db2s_trace.log' -exec ls -lrt {} \; 2>/dev/null
find /var -name db_mon.cfg 2>/dev/null

==Indoubt transaction==
select local_tran_id, state, FAIL_TIME,FORCE_TIME,RETRY_TIME from dba_2pc_pending
order by FAIL_TIME;

==Sessions waiting (Resource in high demand)==


select active_session_history.event,
sum(active_session_history.wait_time +
active_session_history.time_waited) ttl_wait_time
from v$active_session_history active_session_history
where active_session_history.sample_time between sysdate - 60/2880 and sysdate
group by active_session_history.event
order by 2

== Session Wait (User)==


select sesion.sid,
sesion.username,
sum(active_session_history.wait_time +
active_session_history.time_waited) ttl_wait_time
from v$active_session_history active_session_history,
v$session sesion
where active_session_history.sample_time between sysdate - 60/2880 and sysdate
and active_session_history.session_id = sesion.sid
group by sesion.sid, sesion.username
order by 3

==SQL Using the most Resource==


col OBJECT_NAME for a40
select active_session_history.user_id,
dba_users.username,
sqlarea.sql_text,
sum(active_session_history.wait_time +
active_session_history.time_waited) ttl_wait_time
from v$active_session_history active_session_history,
v$sqlarea sqlarea,
dba_users
where active_session_history.sample_time between sysdate - 60/2880 and sysdate
and active_session_history.sql_id = sqlarea.sql_id
and active_session_history.user_id = dba_users.user_id
group by active_session_history.user_id,sqlarea.sql_text
order by 4;

==Object Using the Most Resource==


set linesize 200
col OBJECT_NAME for a40
col OBJECT_TYPE for a20
col EVENT for a40
select dba_objects.object_name,
dba_objects.object_type,
active_session_history.event,
sum(active_session_history.wait_time +
active_session_history.time_waited) ttl_wait_time
from v$active_session_history active_session_history,
dba_objects
where active_session_history.sample_time between sysdate - 60/2880 and sysdate
and active_session_history.current_obj# = dba_objects.object_id
group by dba_objects.object_name, dba_objects.object_type,
active_session_history.event
order by 4;

==Application Using the most resource==


clear col bre comp
set linesize 200
col username format a15
col osuser format a10
col sid format a10
col serial format 99999
col pid format a5
col event format a30
col login_time format a11
col wait_class format a14
col module format a14
col sec format 999999
select s.username, s.osuser, spid pid, s.sid||' '||s.serial# sid,
to_char(s.logon_time, 'DD/MM HH24:MI') login_time,
decode(s.sql_id, null, s.prev_sql_id, s.sql_id) sql_id, s.event, s.seconds_in_wait
sec, s.wait_class, substr(s.module,1,14) module
from v$session s, v$process p
where addr=paddr
and status='ACTIVE'
and s.username is not null
and (client_info is null or client_info != 'Me')
order by type, sid;

==Enqueue Wait Event==


SELECT DECODE(request,0,'Holder: ','Waiter: ')||sid sess,
id1, id2, lmode, request, type
FROM V$LOCK
WHERE (id1, id2, type) IN
(SELECT id1, id2, type FROM V$LOCK WHERE request>0)
ORDER BY id1, request;

==Session wait for events==


select event, sid, state, wait_time, seconds_in_wait
from v$session_wait
order by event, sid;

==SQL Server Querry command for last backup==


SELECT Database_Name,
CONVERT( SmallDateTime , MAX(Backup_Finish_Date)) as Last_Backup,
DATEDIFF(d, MAX(Backup_Finish_Date), Getdate()) as Days_Since_Last FROM
MSDB.dbo.BackupSet
GROUP BY Database_Name
ORDER BY 3 DESC

==Undo Retention Alteration==


alter system set undo_retention=7200 scope=memory;

show parameter undo_retention;

==SQL Checking of job if enabled in environment==


select job_name, job_type, program_name, schedule_name, job_class
from dba_scheduler_jobs

==Buffer Cache Hit Ratio==


select
100*(1 - (v3.value / (v1.value + v2.value))) "Cache Hit Ratio [%]"
from
v$sysstat v1, v$sysstat v2, v$sysstat v3 where
v1.name = 'db block gets' and
v2.name = 'consistent gets' and
v3.name = 'physical reads' ;

==Transaction Rolled back


select LOCAL_TRAN_ID, GLOBAL_TRAN_ID,STATE, FAIL_TIME, FORCE_TIME from
dba_2pc_pending;
.....
7.12.2819598 48801.73C61EC3AF116DD508F0 prepared 2010-06-14
00:33:15
1.13.14198014 48801.6F671EC3AF116DD508F0 prepared 2010-06-14
00:16:29

22 rows selected.

SQL> rollback force '7.12.2819598'


2 ;
Rollback complete.

SQL> rollback force '1.13.14198014';

==Invalid Objects==
col owner for a30
col object_type for a30
col object_name for a30
col status for a30
select owner, object_type, object_name, status from dba_objects
where status != 'VALID'
order by owner, object_type;

==Open cursor==
select a.username, a.sid, b.value
from v$session a, v$sesstat b, v$statname c
where b.sid = a.sid
and c.statistic# = b.statistic#
and c.name = 'opened cursors current'
order by 3 desc;

select sum(b.value)
from v$session a, v$sesstat b, v$statname c
where b.sid = a.sid
and c.statistic# = b.statistic#
and c.name = 'opened cursors current'

==archive log info==


archive log list

==Check user memory limits and swap space==


ulimit -a

==Listener Password Location==


more $ORACLE_HOME/network/admin/listener.ora | grep -i pass

==Blocked Process(SQL)==
IF EXISTS
(SELECT * FROM master.dbo.sysprocesses
WHERE spid IN (SELECT Blocked FROM master.dbo.sysprocesses))
SELECT spid, status, loginame=SUBSTRING(loginame,1,12),
hostname=substring(hostname, 1, 12),
blk=CONVERT(char(3), blocked),
dbname=SUBSTRING(DB_NAME(dbid), 1, 10), cmd, waittype
FROM master.dbo.sysprocesses
WHERE spid IN (SELECT blocked FROM master.dbo.sysprocesses)
AND blocked=0
ELSE
SELECT 'No blocking processes found!'

BLOCKING SESSION
================
SELECT
db.name DBName,
tl.request_session_id,
wt.blocking_session_id,
OBJECT_NAME(p.OBJECT_ID) BlockedObjectName,
tl.resource_type,
h1.TEXT AS RequestingText,
h2.TEXT AS BlockingTest,
tl.request_mode
FROM sys.dm_tran_locks AS tl
INNER JOIN sys.databases db ON db.database_id = tl.resource_database_id
INNER JOIN sys.dm_os_waiting_tasks AS wt ON tl.lock_owner_address =
wt.resource_address
INNER JOIN sys.partitions AS p ON p.hobt_id = tl.resource_associated_entity_id
INNER JOIN sys.dm_exec_connections ec1 ON ec1.session_id = tl.request_session_id
INNER JOIN sys.dm_exec_connections ec2 ON ec2.session_id = wt.blocking_session_id
CROSS APPLY sys.dm_exec_sql_text(ec1.most_recent_sql_handle) AS h1
CROSS APPLY sys.dm_exec_sql_text(ec2.most_recent_sql_handle) AS h2
GO

==Blocked Process(ORACLE)==

select 'SID ' || l1.sid ||' is blocking ' || l2.sid blocking


from v$lock l1, v$lock l2
where l1.block =1 and l2.request > 0
and l1.id1=l2.id1
and l1.id2=l2.id2
/

set lines 200


col SQL_TEXT for a70
col USERNAME for a15
col PROGRAM for a30
select c.spid, a.sid, a.serial#, b.sql_text, a.username, a.program
from v$session a, v$sqlarea b, v$process c
where a.sql_address=b.address
and c.ADDR=a.PADDR
and a.sid in (select sid
from v$session
--where USERNAME is not NULL
where spid in ('1073'))
/

alter system kill session '113,2';

CHECK ORACLE PROCESS (WITH PROCESS ID)


======================================
set lines 200
col SID for 999999
col SERIAL# for 999999
col USERNAME for a8
col STATUS for a8
col COMMAND for 999999
col MACHINE for a25
col PROCESS for 999999
col PROGRAM for a46
col "IDLE_TIME (min)" for 999,999.99
select a.SID, c.spid, a.SERIAL#, a.USERNAME, a.STATUS, a.MACHINE, a.PROCESS,
a.PROGRAM, a.LOGON_TIME, a.LAST_CALL_ET/60 "IDLE_TIME (min)"
from v$session a, v$process c
where a.USERNAME is not null
and c.ADDR=a.PADDR
and a.USERNAME !='SYS'
and a.SID in ('113','26')
order by LOGON_TIME
/

==Deadlock Query==
set linesize 160
col SQL_TEXT for a60
col ORACLE_USERNAME for a14
col object_name for a15
select a.SESSION_ID, c.SQL_TEXT, a.ORACLE_USERNAME, d.object_name, d.object_type
from v$locked_object a, v$session b, v$sqlarea c, dba_objects d
where (a.session_id=b.sid and c.address=b.sql_address) and d.object_id=a.object_id;

+==+ORA-00054: resource busy and acquire with NOWAIT specified+==+[A-


IM101550891]
SET LINES 150
SET PAGES 50
SELECT OWNER, INDEX_NAME, DEF_TABLESPACE_NAME
FROM DBA_PART_INDEXES
WHERE OWNER = 'TRANSADM'

+==+Tablespace Verification+==+
SET LINESIZE 120
SET PAGESIZE 50
COL TBS_NAME form A25
COL EXT_MGMT form A5 HEADING "EXT|MGMT"
COL EXT_ALLOC FORM A5 HEADING "EXT|ALLOC"
COL SEG_MGMT FORM A5 HEADING "SEG|MGMT"
SELECT
t.tablespace_name TBS_NAME,
t.status
FROM dba_tablespaces t
WHERE TABLESPACE_NAME LIKE '%1010';

+==+Partition Index Verification+==+


BREAK ON TABLESPACE_NAME SKIP 1
SET LINESIZE 190
SET PAGESIZE 40
COL INDEX_OWNER FOR A15
COL INDEX_NAME FOR A30
COL STATUS FOR A8
COL TABLESPACE_NAME FOR A20
SELECT TABLESPACE_NAME, STATUS, INDEX_NAME, LOGGING, COUNT(PARTITION_NAME) AS "No.
of IX Partition"
FROM DBA_IND_PARTITIONS
WHERE INDEX_OWNER='TRANSADM'
AND TABLESPACE_NAME LIKE '%1010'
GROUP BY TABLESPACE_NAME, STATUS, INDEX_NAME, LOGGING
ORDER BY 1, 2;

+==+Table Partition Verification+==+


BREAK ON TABLESPACE_NAME SKIP 1
SET LINESIZE 190
SET PAGESIZE 40
COL TABLE_NAME FOR A30
COL TABLESPACE_NAME FOR A20
SELECT TABLESPACE_NAME, TABLE_NAME, COUNT(PARTITION_NAME) AS "No. of Table
Partition"
FROM DBA_TAB_PARTITIONS
WHERE TABLE_OWNER = 'TRANSADM'
AND TABLESPACE_NAME LIKE '%1010'
GROUP BY TABLESPACE_NAME, TABLE_NAME
ORDER BY 1,2;
===================================================================================
===================================================================================
=====================
>dbspicao
usage: dbspico10.exe -c monitor_name -m range [-t tag] [-x {suffix=suffix_name}] [-
v] [-i instance]
usage: dbspico10.exe -r number -m range [-v] [-i instance]
usage: dbspico10.exe -p -m range [-v] [-i instance]
usage: dbspico10.exe -d [-f] [-v] [-i instance]
usage: dbspico10.exe -l [-v] [-i instance]

select tablespace_name,
(total_blocks*8192)/1024/1024 size_mb,
(used_blocks*8192)/1024/1024 used_mb,
(free_blocks*8192)/1024/1024 free_mb
from v$sort_segment

ps -ef |grep exp


/

+++++++++++++++++sharepool+++++++++++++++++
select a.pool, sum(a.bytes/1048576) AS total, b.Free_Memory from v$sgastat a,
(select pool, sum(bytes/1048576) AS Free_Memory from v$sgastat where name
='free memory' group by pool) b
where a.pool = b.pool
group by a.pool, b.Free_Memory;
+++++++++++++++++sharepool+++++++++++++++++

arrange big filesystem


++++++++++++++++++++++++++++++++

du -sk * |sort +0nr


du -sh * |sort +0nr

du -sk * |sort -nr | more

++++++++++++++++++++++++++++++++

TO CHECK IF HOT BACKUP IS FINISHED


oracle@bugs[gcgprd]/usr/local/nb/logs > tail -f oracle_rman_hot.gcgprd.15046.log

SHARED POOL ALTERATION


--------------------------------------------------------------------------------

alter system set shared_pool_size=640M scope=both;


SHARED POOL ADVICE
--------------------------------------------------------------------------------

set lines 200


col SHARED_POOL_SIZE_FOR_ESTIMATE heading 'Pool|Size (MB)'
col SHARED_POOL_SIZE_FACTOR heading 'Size|Factor'
col ESTD_LC_SIZE heading 'Est.|LC (MB)'
col ESTD_LC_MEMORY_OBJECTS heading 'Est. |Mem. LC'
col ESTD_LC_TIME_SAVED heading 'Est. Time|Saved (sec)'
col ESTD_LC_TIME_SAVED_FACTOR heading 'Est. Parsed|Saved Factor'
col ESTD_LC_MEMORY_OBJECT_HITS heading 'Est.|Object Hits' format 99,999,999,999
select * from v$shared_pool_advice;

FOR CRONTAB (iserdb03ftc and inem2ldv) - Archive Space Too Low


-----------------------------------------------------------------------------------
-
-get archive location:

archive log list

-confirm free space

df -k /db/vflmnpp1/arch01/arch
df -k /db/vfpslp/arch2/arch

-determine script to run:


login as root <exit to unix as berond> $/usr/local/bin/sudo su - root
crontab -l | grep vflmnpp1

-run script for archiving


/usr/local/nb/scripts/oracle_rman_log_bu_clusterwrapper.sh vflmnpp1 FTC_RMAN_LOG_DW
0.01
/usr/local/nb/scripts/oracle_rman_log_bu_clusterwrapper.sh vfpsp2 LDV_RMAN_LOG_DW 1

To CHECK ORA ERROR


-----------------------------------------------------------------------------------
-
sqlplus -s "/ as sysdba" << EOF
col instance_name new_value inst_name
select instance_name from v\$instance;
col alert new_value alert_log
select 'cat ' || value || '/alert_' || '&inst_name' || '.log' || ' | tail -3000' ||
' | egrep ' || '''' || 'Shutting|Starting|ORA-|Mon|Tue|Wed|Thu|Fri|Sat|Sun|Errors'
|| '''' alert
from v\$parameter where name='background_dump_dest';
host &alert_log;
EOF

TO REMOVE LOG Files (/db2logbkup/mmlogbkup)


--------------------------------------------
rm S006****.LOG
TO FIND THE LARGEST FILES IN THE FILESYSTEM
--------------------------------------------
find <filesystem> -xdev -size +5000 -exec ls -lrt {} \; | sort -rnk 5 | head -30

OTHER THAN . ORAENV


-------------------
oracle@[vfwadd1]/opt/oracle > . oraenv
ORACLE_SID = [vfwadd1] ?

oracle@[vfwadd1]/opt/oracle > more /etc/oratab^C

oracle@[vfwadd1]/opt/oracle > . ./vfwlpprd.env


@iserdb01ldv:/usr/local/oracle/scripts$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.3.0 - Production on Tue Jul 19 16:54:07 2011

Copyright (c) 1982, 2006, Oracle. All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

GLOBAL_NAME
-----------------------------------------------------------------------------------
-------------------------------------------------
VFWADD1

DBSPI-0066: Alert log size 31.10 MB too big for BIV2 >=30 MB. [Policy:DBMON-DBSPI-
0066-ARM]: ALERT LOG FILE TOO BIG
-----------------------------------------------------------------------------------
----------------------------------
su - oracle
BIV2
show parameter back (to show folder of alert log)
cd <alert log path>
ls -lrt
gzip alert_BIV2.log && touch alert_BIV2.log (zip alert log file and create a new
alert log file with the same name)
mv alert_BIV2.log.gz alert_BIV2.log07242011.gz (rename zipped file)

gzip /tools/oracle/product/9.2.0.1-64/network/log/lsnr_vfivrp1.log && touch


/tools/oracle/product/9.2.0.1-64/network/log/lsnr_vfivrp1.log

DBSPI-0081: 1.00 snapshot errors found in database FBOPERP. [Policy:DBMON-DBSPI-


0081-ARM]
-----------------------------------------------------------------------------------
--------
report-zeus[root] (root dapat)
/var/opt/OV/bin/instrumentation/dbspicao -r1 -m81 -i FBOPERP / FBOPERP AND CHECK
STALENESS (stale dapat. if stale, proceed on closing)
if not stale: alter materialized view MFG_RR.MV_ACTIVITY compile; (replace
SERVICEDESK.SD_GETGLOBAL with OWNER.MVIEW_NAME [MFG_RR.MV_ACTIVITY])
alter materialized view AGGLVLCRITERIA compile;

set lines 200


select owner, mview_name, refresh_mode, refresh_method, staleness, compile_state
from all_mviews
where owner='ABPP';

For Truncating for Drive G (vms-gnb-sbzd51.apps01.valeo)


--------------------------------------------------------
USE [BICRM_UDD_MARKNAD]
GO
DBCC SHRINKFILE (N'BICRM_Marknad_UDD_log' , TRUNCATEONLY)
backup log BICRM_UDD_MARKNAD with truncate_only
DBCC SHRINKFILE (N'BICRM_Marknad_UDD_log' , TRUNCATEONLY)
GO

USE [RSCDATA]
GO
DBCC SHRINKFILE (N'RSCDATA_Log' , TRUNCATEONLY)
backup log RSCDATA with truncate_only
DBCC SHRINKFILE (N'RSCDATA_Log' , TRUNCATEONLY)
GO

USE [WSS_Content_Intranet_Projects_4]
GO
DBCC SHRINKFILE (N'WSS_Content_Intranet_Projects_4_log' , TRUNCATEONLY)
backup log WSS_Content_Intranet_Projects_4 with truncate_only
DBCC SHRINKFILE (N'WSS_Content_Intranet_Projects_4_log' , TRUNCATEONLY)
GO

for older versions of SQL (2008)


BACKUP LOG DBNAMe TO DISK=�NUL:�

USE [BICRM_UDD_MARKNAD]
GO
DBCC SHRINKFILE (N'BICRM_Marknad_UDD_log', 2)
BACKUP LOG BICRM_UDD_MARKNAD TO DISK='NUL:'
DBCC SHRINKFILE (N'BICRM_Marknad_UDD_log', 2)
GO

USE [CODitCIP]
GO
DBCC SHRINKFILE (N'CODitCIP_log' , TRUNCATEONLY)
backup log CODitCIP with truncate_only
DBCC SHRINKFILE (N'CODitCIP_log' , TRUNCATEONLY)
GO

1. check largest LDF File in the drive. It will be the truncated file.
2. Have it backed up with B&S team.
3. Upon confirmation of backup, truncate it [double check with database name &
transaction logs (from properties)].
SCRIPTS that were ran
---------------------
rman
connect target /

run {
allocate channel c1 type disk format '/dbcluster2/oraback/act11/db-%I-%T-%t.bkp';
backup as compressed backupset tag full_db_online incremental level 1 database
NOEXCLUDE plus archivelog;
delete noprompt archivelog all completed before 'sysdate-1';
};

FOR DBSPI10-82: Data logging failed for ORAOSM_METRICS. Make sure Performance
Agent is installed and running. (Error 256 occurred.)
-----------------------------------------------------------------------------------
-------------------------------------------------
1)Execute: find / -name opcagt
3) cd /usr/lpp/OV/bin/OpC/ OR /usr/lpp/OV/bin/opcagt -status
2)Execute: opcagt -status

ps -ef | grep db2sys


ps -ef | grep db2sysc
db2 list active databases
pa putty sa server
pag putty sa server

Size of 1000000000
/var/lpp/OV/db2spi/log/
mv db2spi.log db2spi.log20120212 && touch db2spi.log
gzip db2spi.log201101011

For XP3
===================================================================================
===
(Go to RMAN first: RMAN target/)
delete noprompt force archivelog until time='sysdate-1';

6:26 PMManalon, Katrina Marie Poraxp3@p009dae0XP3)> df -k


/oracle/XP3/arch/oradata/DS/arc
Filesystem 1024-blocks Free %Used Iused %Iused Mounted on
/dev/p009xp3vg1lv04 4194304 2345752 45% 217 1% /oracle/XP3/arch
oraxp3@p009dae0XP3)> uname -a;date
AIX p009dae0 3 5 00C4973E4C00
Mon Aug 29 20:24:59 EET 2011

CLEANING ORA LISTENER LOGS


===================================================================================
================================
tail -2000 listener.log > listener.log.20130102 --- save the last 2000 lines
into new file, listener.log.<date>
echo " " > listener.log ---- empty listener.log
gzip listener.log.20110912 --- gzip new file to further save space

mv listener.log listener.log.20120102 && touch listener.log; gzip


listener_cogp.log.02012012

!!!OR

cat alertlogwatch.log | gzip >alertlogwatch.log.20130215.gz && cp /dev/null


alertlogwatch.log

Listener log file backup and zip. Start the listener control utility
lsnrctl
set current_listener lsnr_t625
show log_status
set log_status off
## here you rename the logfile
set log_status on
show log_status
## Later you can zip the renamed logfile

FOR ETPTA (LISTENER)


===================================================================================
=================================
1. Check whether DB is up and running.
2. If Listener is down, check whether set TNS admin and the must-be TNS admin are
the same.
3. check lsnrctl status ETPTA
4. Go to /etc/ora (admin-zeus[oracle]/etc/ora) and check oratab
5. Check corresponding TNS_admin: admin-zeus[oracle]/etc # more oratab
6. if there is a discrepancy between the TNS admins, set accordingly by: export
TNS_ADMIN=/u00/app/oracle/product/9.2.0/network/admin (or change accordingly)
7. check listener status for ETPTA and resolve ticket.
tail -200 /var/tmp/hp_ora_netbackup.log | grep
/backup2/bk_206650_1_787887020_GOBDPRD_log
/backup2/bk_151044_1_763183363_GOBDPRD_log

find /dbteam -size +5000 -xdev -exec ls -l {} \; | sort -nrk 5 | head


find /var -size +5000 -xdev -exec ls -l {} \; | sort -nrk 5 | head

fuser /db/gobdprd/oracle_export/gobdprd/gobdprd111031.dmp

BY DATE
find . -type f -mtime +1250 -exec ls -l {} \;
MUTTLY (/var)
===================================================================================
=====================================
gzip -c hp_ora_backup_log.hist >
/db/gobdprd/index01/hp_ora_backup_db_hist_from_var/hp_ora_backup_log.hist.20111221.
gz

gzip -c gobdprd.fulldb.dmp > /oracle_backup/gobdprd/gobdprd.fulldb.dmp02062012.gz

ito yung pan check dun sa indexes


select index_owner, index_name, partition_name, status
from dba_ind_partitions
where INDEX_NAME in ('SMS_IMEI_IDX', 'SMS_MT_MSISDN_IDX',
'SMS_MO_MSISDN_IDX','GPRS_CUS_MO_MSISDN_IDX','GPRS_CUS_REPORT_TIME_IDX')
and partition_name in ('P_SMS_20110915','P_GPRS_CUS_20110915');

11:55 PMManalon, Katrina Marie Pok po

11:55 PMLasola, Gertony MINDEX_OWNER INDEX_NAME


PARTITION_NAME STATUS
------------------------------ ------------------------------
------------------------------ --------
TRANSADM GPRS_CUS_MO_MSISDN_IDX P_GPRS_CUS_20110915
UNUSABLE
TRANSADM GPRS_CUS_REPORT_TIME_IDX P_GPRS_CUS_20110915
UNUSABLE
TRANSADM SMS_IMEI_IDX P_SMS_20110915
UNUSABLE
TRANSADM SMS_MT_MSISDN_IDX P_SMS_20110915
UNUSABLE
TRANSADM SMS_MO_MSISDN_IDX P_SMS_20110915
UNUSABLE
need natin gawing usable

11:55 PMManalon, Katrina Marie Paaah

11:55 PMLasola, Gertony Mmamaya ito ang need natin i run


ALTER TABLE TRANSADM.GPRS MODIFY PARTITION P_GPRS_CUS_20110915 REBUILD UNUSABLE
LOCAL INDEXES;
ALTER TABLE TRANSADM.SMS MODIFY PARTITION P_SMS_20110915 REBUILD UNUSABLE LOCAL
INDEXES;

RPA SCRIPT
========================================================
db2 -tvf GRANT_ACCESS_SM_TROYKE.sql -z GRANT_ACCESS_SM_TROYKE.out
db2 -tvf ISSR_Switch_EXC_EXT_IVD_Validation_On11292011.sql -z
ISSR_Switch_EXC_EXT_IVD_Validation_On11292011.out
db2 -tvf ISSR_Switch_PRG_Validation_On11292011.sql -z
ISSR_Switch_PRG_Validation_On11292011.out
db2 -tvf CH_Switch_EXT_IVD_Validation_On11292011B.sql -z
CH_Switch_EXT_IVD_Validation_On11292011B.out

RECREATING ALERT LOG


=======================
oracle@dionysus[icprd]/tools/app/oracle/admin/ictst/bdump > touch alert_ictst.log

SCWEPPES XP3
================
to get rman:
archive log list
cd ^
rman target rmanadmin
(password is hpy personal password)

EUTRADEOMC
==========
If cannot connect to server, check Net/HW and use Primary IP / NAT.

FINDING A FILE: find / -name <filename>

LOCATING ORA-ERRORS IN THE ALERT LOG


===================================================================================
===================================================================================
=
sqlplus -s "/ as sysdba" << EOF
col instance_name new_value inst_name
select instance_name from v\$instance;
col alert new_value alert_log
select 'cat ' || value || '/alert_' || '&inst_name' || '.log' || ' | tail -3000' ||
' | egrep ' || '''' || 'Shutting|Starting|ORA-|Mon|Tue|Wed|Thu|Fri|Sat|Sun|Errors'
|| '''' alert
from v\$parameter where name='background_dump_dest';
host &alert_log;
EOF

VALEO: Basta may SMX / EPM sa server name, hindi sa atin. Matrix Server yun.

RENAMING LOG FILES in DB2:


==========================
mv /db2instance/db2home/mminst/capture/mminst.MMDB.SIVIEWASN.CAP.log
/db2instance/db2home/mminst/capture/mminst.MMDB.SIVIEWASN.CAP.log.20120524 && touch
/db2instance/db2home/mminst/capture/mminst.MMDB.SIVIEWASN.CAP.log

CREATING USER ACCOUNT AND GRANTING ACCESS (Oracle)


==================================================
CREATE USER LYDONA IDENTIFIED BY "pass123"
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP
ACCOUNT UNLOCK;

grant CONNECT,RESOURCE to borchans;

col segment_name format a40


select owner
, segment_type
, segment_name
, max_extents - extents as "spare"
, max_extents
from dba_segments
where owner not in ('SYS','SYSTEM')
and (max_extents - extents) < 10
order by 4;

SIRIUS
================================
EUTRADEOMC\manalon
tlcm34ar
sqlplus /nolog
conn sys as sysdba
conn sys@<DB> as sysdba

WC2 and/or CAE-Bench TSM DB Backup: DB Backup Errors on 21.12.2011


==================================================================
Go to /sap_ora_tsm/ora_hp/dasi/log/rman/
To search rman log with specified instance & date, execute ls -alrt *T633*20111221*
UNLOCKING ACCOUNT IN ORACLE / UNLOCK ACCOUNT
=============================================
alter user mbss identified by mbss123 account unlock;

For Checking Privileges (DBA_TAB_PRIVS)

FOR CREATING TEST JOBS IN MS SQL


eto lagay mo na script
Select t set from master
step name : Test
Type: Transaction-SQL script(TSQL)
Database:master
by default naman ata yan talaga yung setting..

FOR CREATING TEST JOBS IN ORACLE


execute: alter something na mali yung script :)

Redo Log
============================================================
1. Check status:

set linesize 200


col member for a70
select a.group#,a.member,b.bytes/1024/1024 "size", b.status
from v$logfile a, v$log b
where a.group# = b.group#;

OR

select group#, status from v$log;

2. alter system switch logfile;

IF LOCAL.CFG / INSTANCE5 NOT LISTED IN DBSPICFG -E


Open cmd prompt and input: c:/temp/dbspicfg -e > local.cfg.txt
edit local.cfg and add the instance, save text file
then import: c:\temp\dbspicfg -i < local.cfg.txt

DATA LOGGING FAILED


PATH = %PATH%;%OVDATADIR%\bin\instrumentation
PATH = %PATH%;%OVINSTALLDIR%\bin
PATH = %PATH%;%OVINSTALLDIR%\bin\win64
dbspimwi -cleanup
ovc -stop coda
ovpacmd stop --mwacmd stop
TYPE "%OVDATADIR%\conf\perf\datasources" | FINDSTR /i dbspi (should be none)
del C:\usr\ov\dbspi\dsi\mssql\*.*
del C:\usr\ov\dbspi\dsi\mssql\osm\*.*
del C:\usr\ov\dbspi\dsi\mssql\udm\*.*
MOVE c:\usr\ov\dbspi\dsi\mssql c:\usr\ov\dbspi\dsi\mssql.old
ovc -start coda
ovpacmd start --mwacmd start (wait for 10 minutes)
########DB COnnection Check#############
#dbspicam -d -v -f -p
########Logging of Metrics##############
dbspimwi
dbspimwi -osm
dbspimwi -udm
ovc -stop coda
ovpacmd stop
ovc -start coda
ovpacmd start
dbspiadm conncheck

checking FS with highest utilizations


du -sk ./*

DB SIZE / DATABASE SIZE


col "Database Size" format a20
col "Free space" format a20
col "Used space" format a20
select round(sum(used.bytes) / 1024 / 1024 ) || ' MB' "Database Size",
round(sum(used.bytes) / 1024 / 1024 ) - round(free.p / 1024 / 1024 ) || ' MB' "Used
space",
round(free.p / 1024 / 1024 ) || ' MB' "Free space"
from (select bytes
from v$datafile
union all
select bytes
from v$tempfile
union all
select bytes
from v$log)
used, (select sum(bytes) as p
from dba_free_space) free
group by free.p
/

CHECKING SERVER UPTIME IN WINDOWS/UNIX


uptime :)

HOUSEKEEPING TRACE FILES


Go to the udump/bdump/cdump location
find . -name "*.trc" -mtime 90 -exec rm -rf {} \;
90 = 3-month old files

BACKUP CHECK
============================================
Select recid,
set_count,
backup_type,
Incremental_level Ilevel,
to_char(completion_time,'mm/dd/yy hh24:mi') Completed
From v$backup_set
Where backup_type='D';

select file_name, COMPLETION_TIME from dba_data_files a, V$BACKUP_DATAFILE b where


FILE#=file_id;

ACTIVE SESSIONS
===================================================================================
============================
set lines 200
col SID for 999999
col SERIAL# for 999999
col USERNAME for a12
col STATUS for a8
col COMMAND for 999999
col MACHINE for a27
col PROCESS for 999999
col PROGRAM for a40
col "IDLE_TIME (min)" for 999,999.99
select SID, SERIAL#, USERNAME, STATUS, MACHINE, PROCESS, PROGRAM, LOGON_TIME,
LAST_CALL_ET/60 "IDLE_TIME (min)"
from v$session
where USERNAME is not null
and USERNAME !='SYS'
--and SID in ('46','14','9','16')
order by LOGON_TIME
/

ACTIVE SESSIONS with SQL TEXT


===================================================================================
============================
set lines 200
set pages 5000
set long 50000
col SPID for 999999
col SQL_TEXT for a105
col USERNAME for a15
col PROGRAM for a30
col STATUS for a7
col "IDLE (min)" for 999,999.99
select c.spid, a.sid, a.serial#, b.sql_text, a.status, a.LAST_CALL_ET/60 "IDLE
(min)"
from v$session a, v$sqlarea b, v$process c
where a.sql_address=b.address
and c.ADDR=a.PADDR
and a.sid in ('113','26')
/

CPUHOG (GET DETAILS)


set lines 200
set pages 5000
set long 50000
col SPID for 999999
col SQL_TEXT for a105
col USERNAME for a15
col PROGRAM for a30
col STATUS for a7
col "IDLE (min)" for 999,999.99
select c.spid, a.sid, a.serial#, b.sql_text, a.status, a.LAST_CALL_ET/60 "IDLE
(min)"
from v$session a, v$sqlarea b, v$process c
where a.sql_address=b.address
and c.ADDR=a.PADDR
and c.spid in ('12731')
/

KILL SESSIONS WITH USERNAME HP_SMSPI


===================================================================================
============================
select 'alter system kill session '''||SID||','||SERIAL#||''' immediate;'
from v$session
where USERNAME = 'HP_SMSPI'
/

SYNC ARCHIVELOGS OF PRIMARY WITH STANDBY


==============================================================================
PRIMARY:
select max(sequence#) from v$log_history;

STANDBY:
select sequence#, archived, applied from v$archived_log order by sequence#;
select sequence#, archived, applied from v$archived_log where applied='NO' order by
sequence#;
select count(*) from v$archived_log where applied='NO';
alter database recover managed standby database disconnect from session;

alter database register logfile 'L:\MXVSDS\AdminArch\Stby\ARC85170.001';

Steps to activate standby database

1. startup nomount
2. alter database mount standby database;
3. alter database recover managed standby database disconnect from session;
STOPPING A SERVICE / PROCESS IN WINDOWS (MSSQL)
1. net stop <service_name>
2. if #1 fails, sc queryex <service_name>, get PID
3. taskkill /f /pid <PID>

LONG-RUNNING PROCESS
===================================================================================
================================
set lines 200
col SID for 999999
col SERIAL# for 999999
col USERNAME for a12
col STATUS for a8
col COMMAND for 999999
col MACHINE for a27
col PROCESS for 999999
col PROGRAM for a40
col "IDLE_TIME (min)" for 999,999.99
select SID, SERIAL#, USERNAME, STATUS, MACHINE, PROCESS, PROGRAM, LOGON_TIME,
LAST_CALL_ET/60 "IDLE_TIME (min)"
from v$session
where USERNAME is not null
and USERNAME !='SYS'
--and SID in ('46','14','9','16')
order by LOGON_TIME
/

DISABLING JOBS
execute dbms_job.broken(<job number>,true);
execute dbms_job.broken(154,true);

set lines 160


set long 50000
set pages 50000
set timing on
alter session set nls_date_format='YYYY-MON-DD HH24:MI:SS';
col what format a30
col interval format a40
col failures format 9999
col job format 9999
col global_name format a30;
select * from global_name;
select job, what, last_date, next_date, interval, failures, broken from dba_jobs;

execute DBMS_JOB.NEXT_DATE(84,'2013-JUN-22 07:00:00');


execute dbms_job.broken(61, FALSE,'2013-JUN-22 06:00:00');
Before setting the allowable maximum server memory, verify the current memory usage
of each instance by executing the query below:

==Memory SQL Server==


SELECT DB_NAME(database_id),
COUNT (*) / 1024 AS MBUsed
FROM sys.dm_os_buffer_descriptors
GROUP BY database_id
ORDER BY COUNT(*) / 1024 DESC

Below is the proposed maximum value for server memory per instance as of the
creation of this change which is subject to adjustment on the actual
implementation.

Instance Current usage


Proposed maximum value in MB
VCX0001P01 not more than 100Mb
6144
VCX0001P01/CDB not more than 100Mb
6144
VCX0001P01/ECA_PROD not more than 6GB 10240
VCX0001P01/FEKO_PROD not more than 7GB 10240
VCX0001P01/IVT not more than 8Gb
10240
VCX0001P01/VAPA_PROD not more than 100Mb 6144
VCX0001P01/MSP not more than 500Mb
6144
VCX0001P01/INR not more the 600Mb
6144

To set a fixed amount of memory, there are 2 options. One is using the GUI and the
other is using the command line:

A. GUI
In Object Explorer, right-click a server and select Properties. Click the Memory
node.
Under Server Memory Options, enter the amount that you want for Minimum server
memory and Maximum server memory.

B. Command line
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'max server memory', 6144;
GO
RECONFIGURE;
GO

Then, restart MS SQL Service for each instance.

Instance Database
VCX0001P01 ReportServer
VCX0001P01 ReportServerTempDB
VCX0001P01/CDB ShopExpress
VCX0001P01/ECA_PROD ETL_LOG
VCX0001P01/ECA_PROD LA_BR
VCX0001P01/ECA_PROD LA_NBD
VCX0001P01/ECA_PROD PubEasy
VCX0001P01/ECA_PROD SA_ABG
VCX0001P01/ECA_PROD SA_BOKUS
VCX0001P01/ECA_PROD SA_BR
VCX0001P01/ECA_PROD SA_EXTLEV
VCX0001P01/ECA_PROD SA_NBD
VCX0001P01/ECA_PROD SA_TEMPEXTLEV
VCX0001P01/FEKO_PROD FEKO_PROD
VCX0001P01/FEKO_PROD FEKO_PRODTempDB
VCX0001P01/FEKO_PROD ReportServer
VCX0001P01/FEKO_PROD agrprod
VCX0001P01/FEKO_PROD agrtest
VCX0001P01/FEKO_PROD agrutb
VCX0001P01/FEKO_PROD webinfo
VCX0001P01/INR Infra
VCX0001P01/IVT Invit2006Arkiv
VCX0001P01/IVT Invit2006Server
VCX0001P01/MSP MSP
VCX0001P01/VAPA_PROD WEBVOPHQ

Verify if changes were reflected on each instance by executing SP_CONFIGURE on the


command line or by checking the Properties as instructed above.

CHECK SWAP USAGE


[root@vcx0001r0a ~]# free -mot
total used free shared buffers cached
Mem: 129002 128683 318 0 287 124418
Swap: 16095 16095 0
Total: 145098 144779 318
[root@vcx0001r0a ~]#

top - 12:29:24 up 3 days, 14:05, 4 users, load average: 4.80, 3.70, 3.72
Tasks: 735 total, 1 running, 734 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.6%us, 1.2%sy, 0.0%ni, 90.9%id, 5.8%wa, 0.2%hi, 1.3%si, 0.0%st
Mem: 132098152k total, 131770952k used, 327200k free, 296068k buffers
Swap: 16482296k total, 16482296k used, 0k free, 127391656k cached

AVIVA LINK:
https://www.avivaworld.com/sites/USappDevReleaseManagement/Lists/Aviva%20US%20LNA
%20App%20Dev%20Release%20and%20Deployment%20Tracki/SampleView.aspx?
Paged=TRUE&p_GroupCol1=Sheila%20Krieg&p_GroupCol2=A2K
%2dBAU&PageFirstRow=101&&View={4E3D2E74-FA57-4DFD-824D-
0DDCEA5079A3}&InitialTabId=Ribbon%2EListItem&VisibilityContext=WSSTabPersistence

SOLARIS (TOP)
============================
Memory size: 24576 Megabytes

prtconf | grep Mem


TO GET DDL (to view properties of an object)
===================================================================================
===
set long 2000000
set head off
set pagesize 0
select dbms_metadata.get_ddl(�object type�,�object name�,�owner�) from table_name;
example for table:
select dbms_metadata.get_ddl('TABLE','SMSC_MSISDN_TYPE','SUADM') from dba_tables;

example for tablespace:


select dbms_metadata.get_ddl('TABLESPACE','DTW_DATA_TBS') from dba_tablespaces;

example for table index:


select dbms_metadata.get_ddl('INDEX','GSM_FILE_AUDIT_IDX01','SUADM') from
dba_indexes;

The database principal owns a schema in the database, and cannot be dropped.
(Microsoft SQL Server, Error: 15138)
===================================================================================
===========================
Now if you drop the database owner it will not throw any error.

Here is generic script for resolving the error:

SELECT s.name
FROM sys.schemas s
WHERE s.principal_id = USER_ID('YourUserID');

Now replace the result name in following script:

ALTER AUTHORIZATION ON SCHEMA::YourSchemaName TO dbo;

GRANT ORACLE
=========================================================
col owner for a15
col OBJECT_NAME for a20
col OBJECT_TYPE for a20
select OWNER, OBJECT_NAME, OBJECT_TYPE from dba_objects
where OBJECT_NAME
in
('USERPREF',
'SALES_HISTORY',
'ACCRUAL_DATA',
'SALES_HEADER',
'SALES_BANNER',
'USER_MASTER',
'SALES_DEAL',
'USER_ACCOUNT_MAP',
'ORGANISATION',
'PRODUCT_GRIN',
'PRODUCT_SKU',
'PRODUCT',
'PACK_MASTER',
'BRAND_MASTER',
'CUSTOMER_MASTER',
'BUYING_WEEKS',
'FIXED_TERMS',
'GRIN_MAPPING',
'WAR_BA')
/

grant select on TSM.USERPREF',


grant select on TSM.SALES_HISTORY',
grant select on TSM.ACCRUAL_DATA',
grant select on TSM.SALES_HEADER',
grant select on TSM.SALES_BANNER',
grant select on TSM.USER_MASTER',
grant select on TSM.SALES_DEAL',
grant select on TSM.USER_ACCOUNT_MAP',
grant select on TSM.ORGANISATION',
grant select on TSM.PRODUCT_GRIN',
grant select on TSM.PRODUCT_SKU',
grant select on TSM.PRODUCT',
grant select on TSM.PACK_MASTER',
grant select on TSM.BRAND_MASTER',
grant select on TSM.CUSTOMER_MASTER',
grant select on TSM.BUYING_WEEKS',
grant select on TSM.FIXED_TERMS',
grant select on TSM.GRIN_MAPPING',
grant select on TSM.WAR_BA'

UPDATE README
==============
echo "09) Backup before applying its-issr-db.02.08.01_03042013 patches:
20130305153200" >> Readme

echo "4) Backup before applying its-issr-db.02.06.01_P03 patches: 20120711094359"


>> Readme

echo "3) Backup before applying its-sm.db.02.06.01_P01 patches: 20120711095341" >>


Readme

PAS PROD/PREPROD
================
ALLOCATE CHANNEL FOR MAINTENANCE TYPE DISK;
DELETE NOPROMPT ARCHIVELOG UNTIL TIME 'SYSDATE - 1' BACKED UP 1 TIMES TO DEVICE
TYPE DISK;
DELETE NOPROMPT BACKUPSET COMPLETED BEFORE "SYSDATE-1" DEVICE TYPE DISK;
RELEASE CHANNEL;

PERFSTAT
========
1. Log-in as perfstat user and purge old snap ID.
SQL> connect perfstat/perfstat
Connected.

SQL> @?\rdbms\admin\sppurge.sql
*NOTE: SPPURGE is located in D:\oracle\ora9i\rdbms\admin

2. Log-in as sys execute: alter tablespace PERFSTAT coalesce;


3. Rebuild the index using this command:

alter index PERFSTAT.STATS$BG_EVENT_SUMMARY_PK rebuild online;


alter index PERFSTAT.STATS$BUFFER_POOL_STATS_PK rebuild online;
alter index PERFSTAT.STATS$DATABASE_INSTANCE_PK rebuild online;
alter index PERFSTAT.STATS$DB_CACHE_ADVICE_PK rebuild online;
alter index PERFSTAT.STATS$DLM_MISC_PK rebuild online;
alter index PERFSTAT.STATS$ENQUEUE_STAT_PK rebuild online;
alter index PERFSTAT.STATS$FILESTATXS_PK rebuild online;
alter index PERFSTAT.STATS$IDLE_EVENT_PK rebuild online;
alter index PERFSTAT.STATS$INSTANCE_RECOVERY_PK rebuild online;
alter index PERFSTAT.STATS$LATCH_CHILDREN_PK rebuild online;
alter index PERFSTAT.STATS$LATCH_MISSES_SUMMARY_PK rebuild online;
alter index PERFSTAT.STATS$LATCH_PARENT_PK rebuild online;
alter index PERFSTAT.STATS$LATCH_PK rebuild online;
alter index PERFSTAT.STATS$LEVEL_DESCRIPTION_PK rebuild online;
alter index PERFSTAT.STATS$LIBRARYCACHE_PK rebuild online;
alter index PERFSTAT.STATS$PARAMETER_PK rebuild online;
alter index PERFSTAT.STATS$PGA_TARGET_ADVICE_PK rebuild online;
alter index PERFSTAT.STATS$RESOURCE_LIMIT_PK rebuild online;
alter index PERFSTAT.STATS$ROLLSTAT_PK rebuild online;
alter index PERFSTAT.STATS$ROWCACHE_SUMMARY_PK rebuild online;
alter index PERFSTAT.STATS$SEG_STAT_OBJ_PK rebuild online;
alter index PERFSTAT.STATS$SEG_STAT_PK rebuild online;
alter index PERFSTAT.STATS$SESSION_EVENT_PK rebuild online;
alter index PERFSTAT.STATS$SESSTAT_PK rebuild online;
alter index PERFSTAT.STATS$SGASTAT_U rebuild online;
alter index PERFSTAT.STATS$SGA_PK rebuild online;
alter index PERFSTAT.STATS$SHARED_POOL_ADVICE_PK rebuild online;
alter index PERFSTAT.STATS$SNAPSHOT_PK rebuild online;
alter index PERFSTAT.STATS$SQLTEXT_PK rebuild online;
alter index PERFSTAT.STATS$SQL_PGASTAT_PK rebuild online;
alter index PERFSTAT.STATS$SQL_PLAN_PK rebuild online;
alter index PERFSTAT.STATS$SQL_PLAN_USAGE_HV rebuild online;
alter index PERFSTAT.STATS$SQL_PLAN_USAGE_PK rebuild online;
alter index PERFSTAT.STATS$SQL_STATISTICS_PK rebuild online;
alter index PERFSTAT.STATS$SQL_SUMMARY_PK rebuild online;
alter index PERFSTAT.STATS$SQL_WORKAREA_HIST_PK rebuild online;
alter index PERFSTAT.STATS$STATSPACK_PARAMETER_PK rebuild online;
alter index PERFSTAT.STATS$SYSSTAT_PK rebuild online;
alter index PERFSTAT.STATS$SYSTEM_EVENT_PK rebuild online;
alter index PERFSTAT.STATS$TEMPSTATXS_PK rebuild online;
alter index PERFSTAT.STATS$UNDOSTAT_PK rebuild online;
alter index PERFSTAT.STATS$WAITSTAT_PK rebuild online;

RUN A JOB IN VALEO AND DISPLAY IT UPON QUERY


exec dbms_job.run(66);

TO CHANGE DB OWNER IN MSSQL


USE Intranet_SSP_Search_DB
GO

exec sp_changedbowner �SAPL\BAXDX250&dmin�


GO

select suser_sname(SAPL\BAXDX250&dmin) from sys.databases

Or want just a specific database?

select suser_sname(owner_sid) from sys.databases where name = 'Northwind'

TO FIND THE LARGEST FILES IN THE FILESYSTEM


--------------------------------------------
UNIX: find <filesystem> -xdev -size +5000 -exec ls -lrt {} \; | sort -rnk 5 | head
-30
WINDOWS: diruse /m /s /d /Q:500 D:

FULL / TRANSACTION BACKUP (SQL)

For MSSQL Server:


SELECT database_name, backup_start_date, type
FROM msdb.dbo.backupset
WHERE backup_start_date BETWEEN DATEADD(hh, -24, GETDATE()) AND GETDATE()
AND Type = 'D'
ORDER BY backup_set_id DESC
GO

For Oracle:
Select recid,
set_count,
backup_type,
Incremental_level Ilevel,
to_char(completion_time,'mm/dd/yy hh24:mi') Completed
From v$backup_set
Where backup_type='D';

sqlplus system/manager@ITEFRTST
DATABASE SIZE

col "Database Size" format a20


col "Free space" format a20
col "Used space" format a20
select round(sum(used.bytes) / 1024 / 1024 ) || ' MB' "Database Size",
round(sum(used.bytes) / 1024 / 1024 ) - round(free.p / 1024 / 1024 ) || ' MB' "Used
space",
round(free.p / 1024 / 1024 ) || ' MB' "Free space"
from (select bytes
from v$datafile
union all
select bytes
from v$tempfile
union all
select bytes
from v$log)
used, (select sum(bytes) as p
from dba_free_space) free
group by free.p
/

SQL> set linesize 150


SQL> set pagesize 100
SQL> col name format a25
SQL> col text format a100
SQL> select name, text from dba_source where name = 'MAINTENANCE_SCRIPT'
2 order by LINE asc;

NAME TEXT
-------------------------
-----------------------------------------------------------------------------------
-----------------
MAINTENANCE_SCRIPT PROCEDURE "MAINTENANCE_SCRIPT" AS
MAINTENANCE_SCRIPT
MAINTENANCE_SCRIPT v_dynam varchar2(200);
MAINTENANCE_SCRIPT cursor idx_cursor is
MAINTENANCE_SCRIPT select owner, index_name, tablespace_name from
dba_indexes where owner = 'MXEPLM';
MAINTENANCE_SCRIPT
MAINTENANCE_SCRIPT
MAINTENANCE_SCRIPT BEGIN
MAINTENANCE_SCRIPT for c_row in idx_cursor loop
MAINTENANCE_SCRIPT v_dynam := 'alter index '||c_row.owner||'.'||
c_row.index_name||' rebuild tablespace '||c_row.tabl
espace_name||' compute statistics nologging parallel 5';

MAINTENANCE_SCRIPT
MAINTENANCE_SCRIPT execute immediate v_dynam;
MAINTENANCE_SCRIPT end loop;
MAINTENANCE_SCRIPT
MAINTENANCE_SCRIPT END Maintenance_script;

15 rows selected.
or exec get ddl

For MSSQL Server:


SELECT database_name, backup_start_date, type
FROM msdb.dbo.backupset
WHERE backup_start_date BETWEEN DATEADD(hh, -24, GETDATE()) AND GETDATE()
AND Type = 'D'
ORDER BY backup_set_id DESC
GO

For Oracle:
Select recid,
set_count,
backup_type,
Incremental_level Ilevel,
to_char(completion_time,'mm/dd/yy hh24:mi') Completed
From v$backup_set
Where backup_type='L';

Carlo Domogma:
For MSSQL Server:
SELECT database_name, backup_start_date, type
FROM msdb.dbo.backupset
WHERE backup_start_date BETWEEN DATEADD(hh, -24, GETDATE()) AND GETDATE()
AND Type = 'L'
ORDER BY backup_set_id DESC
GO

For Oracle:
Select recid,
set_count,
backup_type,
Incremental_level Ilevel,
to_char(completion_time,'mm/dd/yy hh24:mi') Completed
From v$backup_set
Where backup_type='L';

MSSQL
TOTAL DB COUNT
SELECT count(1)-4 FROM sys.databases

TOTAL DB SIZE in GB
SELECT CONVERT(DECIMAL(10,2),(SUM(size * 8.00) / 1024.00 /1024)) As UsedSpace
FROM master.sys.master_files

CPU
select COUNT(*) from sys.dm_os_schedulers where status = 'VISIBLE ONLINE'
select cpu_count from sys.dm_os_sys_info

PHYSICAL
SELECT cpu_count / hyperthread_ratio AS physical_cpu_sockets
FROM sys.dm_os_sys_info ;

MEMORY
SELECT object_name, counter_name, cntr_value/1024 AS 'Total Server Memory (MB)'
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Total Server Memory (KB)'

TOTAL DATAFILE SIZE IN MB


SELECT SUM((size*8)/1024) Data_in_MB FROM sys.master_files where type_desc =
'rows'

TOTAL LOG SIZE IN MB


SELECT SUM((size*8)/1024) Data_in_MB FROM sys.master_files where type_desc = 'log'

TOTAL BACKUP SIZE


use msdb
go

SELECT
(SUM(backup_size) + SUM(1536)) / 1024 / 1024 As MBs
FROM
backupset
INNER JOIN
(
SELECT
database_name,
MAX(backup_start_date) as LastFullBackupDate
FROM
dbo.backupset
WHERE
type = 'D'
GROUP BY
database_name
) AS GetLastDate
ON
backupset.database_name = GetLastDate.database_name AND
backupset.backup_start_date = GetLastDate.LastFullBackupDate

select substr(sql_text,instr(sql_text,'INTO "'),30) table_name,


rows_processed,
round((sysdate-to_date(first_load_time,'yyyy-mm-dd hh24:mi:ss'))*24*60,1) minutes,
trunc(rows_processed/((sysdate-to_date(first_load_time,'yyyy-mm-dd
hh24:mi:ss'))*24*60)) rows_per_min
from sys.v_$sqlarea
where sql_text like 'INSERT %INTO "%'
and command_type = 2
and open_versions > 0;
select sid, serial#, sofar, totalwork from v$session_longops;

SELECT SID, SERIAL#, opname, SOFAR, TOTALWORK,


ROUND(SOFAR/TOTALWORK*100,2) COMPLETE
FROM V$SESSION_LONGOPS
WHERE
TOTALWORK != 0
AND SOFAR != TOTALWORK
order by 1;

TRANSFERRING FILES
cp -p <file> /tmp
scp manalonk-ua@vpir1ldv:/path of file ./

DB EXPORT
=========
For Schema Export:
set NLS_LANG=AMERICAN_AMERICA.AL32UTF8
set ORACLE_SID=MXVT
exp system@MXVT file=D:\dump\exp_MXVT_20131106.dmp
log=D:\dump\exp_MXVT_20131106.log owner=MX_VT consistent=y

For Full Export:


set NLS_LANG=AMERICAN_AMERICA.AL32UTF8
set ORACLE_SID=MXVT
exp system@MXVT file=R:\exp_MXVT_20131106.dmp log=R:\exp_MXVT_20131106.log full=y
consistent=y

TO KNOW ORACLE USER


===================
$ ls -lrt /var/opt/oracle
total 6
-rw-r--r-- 1 root root 106 Apr 21 2009 oratab_bos
-rw-r--r-- 1 root root 58 Nov 12 2011 oraInst.loc
-rw-rw-r-- 1 ora11 dba 752 Nov 12 2011 oratab

cat oratab

MYSQL
1.- How do I get mysql prompt in linux terminal?

mysql -u root -p
To connect to vcx0001l09: mysql -u root -pbrorDuktig
At the Enter password: prompt, well, enter root's password :)

You can find further reference by typing mysql --help or at the online manual.

TO HEALTHCHECK:
mysqladmin -u root -pbrorDuktig processlist status version

2. How I stop the mysql server from linux terminal?


It depends. Red Hat based distros have the service command:

service mysqld stop


Other distros require to call the init script directly:

To STOP: /etc/init.d/mysqld stop


To START: /etc/init.d/mysqld start