Wednesday, May 5, 2021

db spec

 col "instance_name - date" for a100
 select 'DB : ' || instance_name ||' - '|| version ||'-' || (
select ltrim(rtrim(comments))
from v$osstat
where stat_name='INST_TYPE') "instance_name - date"
from v$instance union
select 'DB HOST : ' || host_name ||' - '|| (
select platform_name
from v$database) || ' - Time ' || to_char(sysdate,'HH24:MI:SS')
from v$instance union
select 'DB Last Started : ' || to_char(startup_time,'DD-MON-YYYY HH24:MI:SS ') Started
from v$instance union
select 'RAC : ' || decode(value,'TRUE','YES '||' - Instance No:' ||userenv('INSTANCE') ||' - Active Nodes: '||
(select count(1)
from V$ACTIVE_INSTANCES ) , 'NO' )
from v$parameter
where name ='cluster_database' union
select 'Exadata : ' || decode(count(*),1,'YES',null)
from DBA_FEATURE_USAGE_STATISTICS
where name ='Exadata' and CURRENTLY_USED ='TRUE' union
---select decode(least(value),0, 'DB HOST SGA SETUP             : MANUAL  ' ,
---     'DB HOST SGA SETUP             : Automatic - '||round(least(value)/(1048576000),0)|| 'GB'
---) DB_HOME_SGA_MGMT
---from v$parameter where name in ( 'sga_target','memory_target')
select 'DB HOST SGA SETUP : ' ||decode(SGA_CURRENT,0,'Manual - '||SGA_MAX,'Automatic- '|| SGA_CURRENT)|| decode( SGA_MAX-decode(SGA_CURRENT,0,sga_max,sga_current),0,' ',' MAX AVL- '||SGA_MAX)||' GB' SGA
from (
select round((
select max(value)
from v$parameter
where name in ('sga_target','memory_target' ))/(1048576*1024)) SGA_CURRENT, round((
select max(value)
from v$parameter
where name in ('sga_max_size','memory_max_target' ))/(1048576*1024)) SGA_MAX
from dual ) union
select 'Flash Back Enabled : ' || flashback_on
from v$database union
select 'Standby Availability : ' || (
select decode(count(*),0,'NO','YES - '||count(*))
from v$archive_dest
where target ='STANDBY' and status ='VALID' ) ||
(select decode(count(*),0,'',' ADG - '||count(*))
from v$archive_dest_status
where recovery_mode='MANAGED REAL TIME APPLY' and status ='VALID' and database_mode='OPEN_READ-ONLY')
from dual union
select 'DB Role : ' || database_role || ' - ' ||protection_mode || decode(database_role,'PRIMARY',' ','- '||PRIMARY_DB_UNIQUE_NAME||'( Primary)')
from v$database union
select 'DB Open Mode : ' || open_mode || ' - ' || log_mode
from v$database
--union
--select 'Estimated Recovery Time(Secs) : ' || estimated_mttr from v$instance_recovery
union
--SELECT 'DB Time Zone                  : ' || TO_CHAR(SysTimeStamp, 'DD-MON-YYYY HH24:MI:SS TZH') from dual
--union
select 'DB Up Time : ' || trunc( sysdate-startup_time )||' Days '|| trunc( mod( (sysdate-startup_time)*24, 24 ) ) || ' Hrs ' || trunc( mod( (sysdate-startup_time)*24*60, 60 ) ) || ' Mins'
from v$instance union
select 'DB SIZE : ' || ltrim(rtrim(to_char(round(last_value/(1048576*1000),2),'999,999,999'))) || ' - GB '
from dba_high_water_mark_statistics
where name ='DB_SIZE' and DBID = (
select dbid
from v$database ) and version = (
select version
from v$instance) union
select 'DB Backup Status : ' || (
select object_type || ' - '|| status || ' - ' || end_time
from (
SELECT /* + opt_param('optimizer_mode','rule') */ OPERATION, STATUS, OBJECT_TYPE, TO_CHAR(START_TIME,'MM/DD/YYYY:hh:mi') as START_TIME, TO_CHAR(END_TIME,'MM/DD/YYYY:hh:mi') as END_TIME
FROM sys.V_$RMAN_STATUS
WHERE START_TIME > SYSDATE -10 and operation ='BACKUP' and object_type like 'DB%' order by recid desc )
where rownum < 2 )
from dual union
select 'DB HOST Resource :' || ' CPUs = '||num_cpus || ','||' Memory = ' || phym ||'GB'
from (
select value num_cpus
from v$osstat
where stat_name = ( 'NUM_CPUS') ) num_cpus,
(select round((value/1073741824),0) phym
from v$osstat
where stat_name = 'PHYSICAL_MEMORY_BYTES' ) phym

 

No comments:

Post a Comment