Ce script SQL permet de coalescer tous les tablespace de la base.
set echo offset heading offset feedback offprompt---------------------------------prompt - Coalesce tous les tablespaces -
prompt---------------------------------set term off
spool tbs_coalesce.tmp
SELECT 'set echo on' FROM dual;
SELECT 'set feedback on' FROM dual;
SELECT
'altertablespace '||tablespace_name||' coalesce;'
FROM
dba_tablespaces
WHEREcontentsnotin ('TEMPORARY','UNDO');
spool offset term on
@tbs_coalesce.tmp
Ce script SQL permet d'obtenir les informations de la base
set echo offset feedback offset linesize 128
column NAME Format a40
column DATAGUARD_BROKER Format a20
column GUARD_STATUS Format a20
prompt-------------------------prompt - Infos base de données -
prompt-------------------------SELECT
NAME,
To_char(CREATED,'DD/MM/YYYY') CREATION,
LOG_MODE,
DATABASE_ROLE,
DATAGUARD_BROKER,
GUARD_STATUS
FROM
V$DATABASE;
Ce script SQL permet d'afficher la liste des fichiers de contrôle de la base
set echo offset feedback offset linesize 160
prompt-----------------------------------prompt - Fichiers de controle de la base -
prompt-----------------------------------column Fichier format a80
SELECT
NAME Fichier,
DECODE (STATUS, '', 'VALID', 'INVALID') "Statut"FROM
V$CONTROLFILEORDERBY
NAME;
Ce script SQL permet d'afficher la liste des tablespaces par défaut ainsi que le nombre d'utilisateurs qui y sont associés
set echo offset feedback offset linesize 512
prompt----------------------------------------prompt - Liste des tablespaces par défaut -
prompt - et le nombre d'utilisateurs associés -
prompt----------------------------------------columncount(username) heading 'Nbre utilisateurs'
SELECT
default_tablespace,
count(username)
FROM
dba_users
WHERE
username notin ('PUBLIC','_NEXT_USER')
GROUPBY
default_tablespace;
SELECT
temporary_tablespace,
count(username)
FROM
dba_users
WHERE
username notin ('PUBLIC','_NEXT_USER')
GROUPBY
temporary_tablespace;
C script SQL affiche la liste des directories (répertoires) de la base
set echo offset feedback offset linesize 256
prompt--------------------------prompt - Directories de la base -
prompt--------------------------column CHEMIN format a80
column NOM format a40
SELECT
OWNER SCHEMA,
DIRECTORY_NAME NOM,
DIRECTORY_PATH CHEMIN
FROM
DBA_DIRECTORIES
ORDERBY
OWNER,
DIRECTORY_NAME;
Ce script SQL affiche la liste des évènements d'attente d'entrées/sorties de la base
set echo offset feedback offset linesize 512
prompt---------------------------------------------prompt - Classement des attentes d' E/S de la base -
prompt---------------------------------------------column event format a30
column segment_type format a10
column segment_name format a20
SELECT
event,
segment_type,
segment_name,
file_id,block_id,
blocks
FROM
dba_extents,
v$session_wait
WHERE
p1text='file#'
AND
p2text='block#'
AND
p1=file_id
AND
p2 between block_id
AND
block_id + blocks
ORDERBY
segment_type,
segment_name;
Ce script SQL affiche la liste des profils de la base
set echo offset feedback offset linesize 512
prompt---------------------------------prompt - Liste des profiles de la base -
prompt---------------------------------SELECTDISTINCTPROFILEFROM
DBA_PROFILES;
Ce script SQL affiche la liste des REDO LOGS de la base
set echo offset feedback offset linesize 512
prompt----------------------------------prompt - liste des REDO LOGS de la base -
prompt----------------------------------column member format a60
column archived format a10
SELECT
A.GROUP#,
B.MEMBER,
A.THREAD#,
A.SEQUENCE#,
A.BYTES,
A.MEMBERS,
A.ARCHIVED,
A.STATUS,
A.FIRST_CHANGE#,
A.FIRST_TIME
FROM
V$LOG A, V$LOGFILE B
WHERE
A.GROUP# = B.GROUP#
ORDERBY
A.GROUP#;
Ce script SQL affiche la liste des rôles attribués de la base
set echo offset feedback offset linesize 512
prompt----------------------------------------prompt - Liste des roles attribues de la base -
prompt----------------------------------------
break on GRANTED_ROLE skip 1
columnADMIN format a8
column DEFAUT format a8
SELECT
GRANTED_ROLE ROLE,
GRANTEE UTILISATEUR,
ADMIN_OPTION ADMIN,
DEFAULT_ROLE DEFAUT
FROM
DBA_ROLE_PRIVS
WHERE
GRANTEE IN (SELECT USERNAME FROM SYS.DBA_USERS)
ORDERBY
GRANTED_ROLE,
ADMIN_OPTION;
Ce script SQL affiche la liste des rôles attribués aux rôles de la base
set echo offset feedback offset linesize 512
prompt--------------------------------------------------prompt - Liste des roles attribues aux roles de la base -
prompt--------------------------------------------------
break on GRANTED_ROLE skip 1
columnADMIN format a8
column DEFAUT format a8
SELECT
GRANTED_ROLE,
GRANTEE,
ADMIN_OPTION ADMIN,
DEFAULT_ROLE DEFAUT
FROM
SYS.DBA_ROLE_PRIVS
WHERE
GRANTEE IN (SELECTROLEFROM DBA_ROLES)
ORDERBY
GRANTED_ROLE,
ADMIN_OPTION;
Ce script SQL affiche la liste des rôles de la base
set echo off feedback off linesize 512 pagesize 50
prompt------------------------------prompt - Liste des roles de la base -
prompt------------------------------SELECTROLE,
PASSWORD_REQUIRED
FROM
DBA_ROLES
ORDERBYROLE;
Ce script SQL affiche l'occupation mémoire de la SGA
set echo offset feedback offset linesize 512
prompt--------------------------------prompt - Occupation memoire de la SGA -
prompt--------------------------------column dummy noprint
column area format a20 heading 'Main SGA Areas'
column name format a20
column pool format a20
column bytes format 999,999,999,999
columnsum(bytes) format 999,999,999,999
break on report
compute sumofsum(bytes) on report
SELECT
1 dummy,
'DB Buffer Cache' area,
name,
sum(bytes)
FROM
v$sgastat
WHERE
pool isnullAND
name = 'db_block_buffers'
GROUPBY
name
UNIONALLSELECT
2,
'Shared Pool',
pool,
sum(bytes)
FROM
v$sgastat
WHERE
pool = 'shared pool'
GROUPBY
pool
UNIONALLSELECT
3,
'Large Pool',
pool,
sum(bytes)
FROM
v$sgastat
WHERE
pool = 'large pool'
GROUPBY
pool
UNIONALLSELECT
4,
'Java Pool',
pool,
sum(bytes)
FROM
v$sgastat
WHERE
pool = 'java pool'
GROUPBY
pool
UNIONALLSELECT
5,
'Redo Log Buffer',
name,
sum(bytes)
FROM
v$sgastat
WHERE
pool isnullAND
name = 'log_buffer'
GROUPBY
name
UNIONALLSELECT
6,
'Fixed SGA',
name,
sum(bytes)
FROM
v$sgastat
WHERE
pool isnullAND
name = 'fixed_sga'
GROUPBY
name
ORDERBY
4 desc;
column area format a20 heading 'Shared Pool Areas'
prompt----------------------------prompt-- Detail du pool partagé --prompt----------------------------SELECT
'Shared Pool' area,
name,
sum(bytes)
FROM
v$sgastat
WHERE
pool = 'shared pool'
AND
name in ('library cache','dictionary cache','free memory','sql area')
GROUPBY
name
UNIONALLSELECT
'Shared Pool' area,
'miscellaneous',
sum(bytes)
FROM
v$sgastat
WHERE
pool = 'shared pool'
AND
name notin ('library cache','dictionary cache','free memory','sql area')
GROUPBY
pool
ORDERBY
3 desc;
Ce script SQL affiche la liste des déclencheurs de la base
set echo offset feed offPROMPT-------------------------------------PROMPT - Liste des déclencheurs de la base -
PROMPT-------------------------------------SELECT
owner UTILISATEUR,
trigger_name TRIGGER,
status STATUT
FROM
all_triggers
WHERE
owner notin ('SYS','SYSTEM')
ORDERBY
owner,
trigger_name;
Ce script SQL affiche la liste des utilisateurs de la base
set echo offset feedback offset linesize 512
prompt-------------------------------------prompt - Liste des utilisateurs de la base -
prompt-------------------------------------columncount(b.object_id) heading 'Nbre d'objets'
SELECT
a.username UTILISATEUR,
a.account_status STATUT,
a.default_tablespace "TABLESPACE PAR DEFAUT",
a.temporary_tablespace "TABLESPACE TEMPORAIRE",
count(b.object_id)
FROM
dba_users a,
dba_objects b
WHERE
a.username = b.owner(+)
GROUPBY
a.username,
a.account_status,
a.default_tablespace,
a.temporary_tablespace
ORDERBY
a.account_status DESC,
a.username;
Ce script SQL afiche la liste des activités du segment de rollback de la base
set echo offset feedback offset linesize 512
prompt---------------------------------------------------------prompt - Liste des activités du segment de rollback de la base -
prompt---------------------------------------------------------SELECT
A.NAME,
B.XACTS,
C.SID, C.SERIAL#,
C.USERNAME, D.SQL_TEXT
FROM
V$ROLLNAME A,
V$ROLLSTAT B,
V$SESSION C,
V$SQLTEXT D,
V$TRANSACTION E
WHERE
A.USN = B.USN
AND
B.USN = E.XIDUSN
AND
C.TADDR = E.ADDR
AND
C.SQL_ADDRESS = D.ADDRESS
AND
C.SQL_HASH_VALUE = D.HASH_VALUE
ORDERBY
A.NAME,
C.SID,
D.PIECE;
Ce script SQL permet de placer hors ligne tous les segments de rollback
set echo offset heading offset feedback offPROMPT--------------------------------------------PROMPT - Mise Hors ligne des segments de rollback -
PROMPT--------------------------------------------set term off
spool rbs_hors_ligne.tmp
SELECT 'set echo on' FROM dual;
SELECT 'set feedback on' FROM dual;
SELECT
'alterrollbacksegment '||segment_name||' offline;'
FROM
dba_rollback_segs
WHERE
segment_name != 'SYSTEM'
AND
status = 'ONLINE';
spool offset term on
@rbs_hors_ligne.tmp
Ce script SQL permet de remettre en ligne tous les segments de rollback
set echo offset heading offset feedback offPROMPT--------------------------------------------PROMPT - Remise en ligne des segments de rollback -
PROMPT--------------------------------------------set term off
spool rbs_en_ligne.tmp
SELECT 'set echo on' FROM dual;
SELECT 'set feedback on' FROM dual;
SELECT
'alterrollbacksegment '||segment_name||' online;'
FROM
dba_rollback_segs
WHERE
segment_name != 'SYSTEM'
AND
status = 'OFFLINE';
spool offset term on
@rbs_en_ligne.tmp
Ce script SQL permet de mettre hors ligne tous les tablespaces
set echo offset heading offset feedback offprompt-----------------------------------prompt - Mise hors ligne des tablespaces -
prompt-----------------------------------set term off
spool tbs_hors_ligne.tmp
SELECT 'set echo on' FROM dual;
SELECT 'set feedback on' FROM dual;
SELECT
'altertablespace '||tablespace_name||' offline;'
FROM
dba_tablespaces
WHERE
tablespace_name notin ('SYSTEM','OUTLN')
AND
status = 'ONLINE';
spool offset term on
@tbs_hors_ligne.tmp
Ce script SQL permet de remettre en lignes tous les tablespaces de la base
set echo offset heading offset feedback offprompt---------------------------------prompt - Mise en ligne des tablespaces -
prompt---------------------------------set term off
spool tbs_en_ligne.tmp
SELECT 'set echo on' FROM dual;
SELECT 'set feedback on' FROM dual;
SELECT
'altertablespace '||tablespace_name||' online;'
FROM
dba_tablespaces
WHERE
tablespace_name notin ('SYSTEM','OUTLN')
AND
status = 'OFFLINE';
spool offset term on
@tbs_en_ligne.tmp
Ce script SQL permet de désactiver tous les déclencheurs de la base
set echo offset head offset feed offPROMPT-------------------------------------------------PROMPT - Desactivation de tous les triggers de la base -
PROMPT-------------------------------------------------
spool triggers_hors_ligne.tmp
SELECT
'altertrigger '||owner||'.'||trigger_name||' disable;'
FROM
all_triggers
WHERE
owner notin ('SYS','SYSTEM')
AND
status = 'ENABLED';
spool offset feed onset echo on
@triggers_hors_ligne.tmp
Ce script SQL permet d'activer tous les déclencheurs de la base
set echo offset head offset feed offPROMPT-------------------------------------------------PROMPT - Re-activation de tous les triggers de la base -
PROMPT-------------------------------------------------
spool triggers_en_ligne.tmp
SELECT
'altertrigger '||owner||'.'||trigger_name||' enable;'
FROM
all_triggers
WHERE
owner notin ('SYS','SYSTEM')
AND
status = 'DISABLED';
spool offset feed onset echo on
@triggers_en_ligne.tmp
Ce script SQL affiche les information sur l'instance et la base
set echo offset feedback offset heading offprompt----------------------------------prompt - Instance et version de la base -
prompt----------------------------------SELECT 'BlockSize = '||value FROM v$parameter where name = 'db_block_size'
UNIONSELECT 'Version = '||banner FROM v$version whererownum = 1
UNIONSELECT 'Instance = '||name FROM v$database
;