Wednesday 26 September 2018

Multi tenant script

check_pdbs.sql
set linesize 100
col open_time format a25
--pdbs
select con_id,name,open_mode,open_time,ceil(total_size)/1024/1024 total_size_in_mb from v$pdbs
order by con_id asc;

--active services
col name format a20
col network_name format a20
select con_id,con_name,name,network_name from v$active_services
order by con_id asc;

--show container id
show con_name

check_pdbs_datafiles.sql
set linesize 500
set pagesize 100
col name format a20
col db_file_name format a80
select b.con_id,b.name,a.name as db_file_name from v$datafile a, v$pdbs b

where a.con_id= b.con_id;
check_pdbs_tablespaces.sql
set linesize 500
set pagesize 100
SELECT d.con_id,d.status "Status", d.tablespace_name "Name", d.CONTENTS "Type",
       d.extent_management "Extent Management",
       TO_CHAR (NVL (a.BYTES / 1024 / 1024, 0), '99,999,990.900') "Size (M)",
          TO_CHAR (NVL (a.BYTES - NVL (f.BYTES, 0), 0) / 1024 / 1024,
                   '99999999.999'
                  )
       || '/'
       || TO_CHAR (NVL (a.BYTES / 1024 / 1024, 0), '99999999.999') "Used (M)",
       TO_CHAR (NVL ((a.BYTES - NVL (f.BYTES, 0)) / a.BYTES * 100, 0),
                '990.00'
               ) "Used %"
  FROM SYS.cdb_tablespaces d,
       (SELECT con_id,tablespace_name, SUM (BYTES) BYTES
            FROM cdb_data_files
        GROUP BY con_id,tablespace_name) a,
       (SELECT   con_id,tablespace_name, SUM (BYTES) BYTES
            FROM cdb_free_space
        GROUP BY con_id,tablespace_name) f
 WHERE d.con_id=a.con_id
 and d.con_id=f.con_id
 and d.tablespace_name = a.tablespace_name(+)
   AND d.tablespace_name = f.tablespace_name(+)
UNION ALL
SELECT d.con_id,d.status "Status", d.tablespace_name "Name", d.CONTENTS "Type",
       d.extent_management "Extent Management",
       TO_CHAR (NVL (a.BYTES / 1024 / 1024, 0), '99,999,990.900') "Size (M)",
          TO_CHAR (NVL (t.BYTES, 0) / 1024 / 1024, '99999999.999')
       || '/'
       || TO_CHAR (NVL (a.BYTES / 1024 / 1024, 0), '99999999.999') "Used (M)",
       TO_CHAR (NVL (t.BYTES / a.BYTES * 100, 0), '990.00') "Used %"
  FROM SYS.cdb_tablespaces d,
       (SELECT   con_id,tablespace_name, SUM (BYTES) BYTES
            FROM cdb_temp_files
        GROUP BY con_id,tablespace_name) a,
       (SELECT   con_id,tablespace_name, SUM (bytes_cached) BYTES
            FROM v$temp_extent_pool
        GROUP BY con_id,tablespace_name) t
 WHERE d.con_id=a.con_id
   AND d.con_id=t.con_id
   AND d.tablespace_name = a.tablespace_name(+)
   AND d.tablespace_name = t.tablespace_name(+)
   order by 1 asc;

No comments:

Post a Comment

Featured post

Postgres commads

 [oracle@Tesdb ~]$ systemctl status postgresql-15 ● postgresql-15.service - PostgreSQL 15 database server    Loaded: loaded (/usr/lib/system...