Post

Visualizzazione dei post da 2017

Individuare Tabelle in Lock

Per individuare la sessione in attesa  select *  from V$SESSION_WAIT  where EVENT = 'enqueue'; SID identifier of session holding the lock P1, P2, P3 determine the resource when event = 'enqueue' SECONDS_IN_WAIT gives how long the wait did occurs SELECT substr(DECODE(request,0,'Holder: ','Waiter: ')||sid,1,17) sess,id1, id2, lmode, request, type, inst_id FROM GV$LOCK WHERE (id1, id2, type) IN (SELECT id1, id2, type FROM GV$LOCK WHERE request>0) ORDER BY id1, request Per individuare la sessione bloccante e quindi che trattiene le risorse select * from v$lock  where block=1; select sid, serial#, username from v$session where sid in (select blocking_session from V$Session ); sid, serial# sono gli identificativi della sessione oracle LOCKWAIT address of the lock waiting, otherwise null ROW_WAIT_OBJ# object identified of the object we are waiting on (object_id of dba_objects)  ROW_WAIT_FILE#, ROW_WAIT_BLOCK#, ROW_WAIT_ROW# sono i file_id , block_id and 

Monitoraggio Processi e Query- Individuare lo stato di EVENT

Vedere gli eventi della session da analizzare SELECT username, sid , serial# , osuser, status FROM  v$session WHERE trunc (logon_time) = to_date( '28/10/2017' , 'dd/mm/yyyy' ) AND   machine = 'nome_server' AND service_name = 'nome_sid' ; SELECT   event   FROM  V$session; SELECT   event  FROM  v$session_wait Di seguito la query per individuare il processo del sistema operativo (spid): SELECT spid FROM   v$process WHERE NOT EXISTS (SELECT 1                   FROM v$session                   WHERE paddr = addr); Per identificate la sessione in corso. SELECT s.sid, s.serial#, p.spid FROM v$process p, v$session s WHERE p.addr = s.paddr AND s.username = 'schema' ; Per individuare i parametri da killare select 'alter system kill session '||''''|| s.sid ||','|| s.serial# ||''';' FROM v$session s,v$process p WHERE p.addr=s.paddr AND s.sid = and p.pr

Dimensione di una tabella

Di seguito alcune query per individuare le dimensioni in MB di una tabella. select segment_name table_name, sum (bytes)/( 1024 * 1024 ) table_size_meg from user_extents where segment_type= 'TABLE' and segment_name = 'nome_tabella' group by segment_name; SELECT owner, segment_name, segment_type, tablespace_name, bytes/ 1048576 MB, initial_extent, next_extent, extents , pct_increase FROM DBA_SEGMENTS WHERE OWNER = 'BILL' AND   SEGMENT_NAME = ' nome_tabella ' AND SEGMENT_TYPE = 'TABLE' ; select segment_name,segment_type,bytes/ 1024 / 1024 MB from dba_segments where segment_type= 'TABLE' and segment_name= ' nome_tabella ' ; select table_name, num_rows, AVG_ROW_LEN , num_rows*AVG_ROW_LEN/ 1024 / 1024 space_in_MB from dba_tables where table_name = ' nome_tabella '

Statistiche di una tabella da Toad

Immagine
Accedere a Toad sotto Schema Browser, selezionare la tabella  e il tab Stats/Size. Di seguito si vede l'ultimo lancio di statistiche su una tabella:  Per lanciare le statistiche pulsante destro sulla tabella e selezionare "Analyze table". 

INVIO EMAIL DA LINEA DI COMANDO

Di seguito l'invio email da linea di comando : echo "Corpo del messaggio" | mailx -s "Oggetto del messaggio" matthew.murdock@marvel.com Invio email con mittente (-r). echo "Corpo del messaggio" | mailx -s "Oggetto del messaggio" -r "Mittente<elektra nacious@marvel.com>"  matthew.murdock@marvel.com Invio email con mittente (-r) e in copia conoscenza (-c). echo  "Corpo del messaggio"  | mailx -s  "Oggetto del messaggio"  -r  "Mittente<elektra nacious@marvel.com>"  -c  puhisher@marvel.com matthew.murdock@marvel.com Un altro comando è mutt vi invio_files.sh #!/bin/bash -x orario=$(date +"_%Y%m%d_%H%M") echo "In allegato il risultato delle query di QBILL." | \ mutt    -a $QBILLDIR/QBILL_query1${orario}.xls    \         -a $QBILLDIR/QBILL_query1${orario}_gd.xls \         -a $QBILLDIR/QBILL_query2${orario}.xls    \         -a $QBILLDIR/QBILL_query2${orari

CREATE DATABASE LINK

Il Database Link è uno schema object in un db, che permette ad un utente di accedere ad un altro db. Il db link permette di accedere a tabelle e viste di un altro db aggiungendo la stringa @<nome_dblink>. Supponiamo di avere due db uno locale S11TEST e uno remoto con service name IAT11F. Vogliamo accedere da S11TEST allo schema pippo del db IAT11F. Verificare che le due macchine si pingano tra loro e inserire nel tnsname.ora della macchina locale S11TEST  la connessione al db remoto. IAT11F.WORLD =   (DESCRIPTION =     (ADDRESS = (PROTOCOL = TCP)(HOST = lab02.dominio.it)(PORT = 1521))     (CONNECT_DATA =       (SERVER = DEDICATED)       (SERVICE_NAME = IAT11F.WORLD)     )   ) Testare da macchina locale ping <ip macchina remota oppure alias> tnsping IAT11F.WOLRD Sul db S11TEST assicurarsi che l'utenza che deve creare il dblink abbia i seguenti privilegi di sistema: - CREATE SESSION - CREATE DATABASE LINK per creare un dblink privato - CREATE PUBL