|
Oracle: Algunas consultas SQL muy útiles para el administrador de Oracle (DBA)
Os mostramos algunas consultas SQL muy útiles para el administrador de Oracle Database: estado de la base de datos Oracle, parámetros generales, ficheros de control, conexiones actuales a Oracle, nombre del ejecutable que se utiliza, nombre del usuario, diccionario de datos (vistas y tablas), IP del servidor, tamaño de la base de datos, versión de Oracle, ...
Definición SQLSQL (Lenguaje de consulta estructurado) es un lenguaje declarativo de acceso a bases de datos relacionales que permite especificar diversos tipos de operaciones en éstas. Una de sus características es el manejo del álgebra y el cálculo relacional permitiendo efectuar consultas con el fin de recuperar, de una forma relativamente sencilla, información de interés de una base de datos, así como también hacer cambios sobre ella. Es un lenguaje de cuarta generación (4GL). Consultas SQL útiles para obtener información sobre Oracle Database
select * from v$instance
select status from v$instance
select * from v$system_parameter
select value
select value
select value
select value
select osuser, username, machine, program from v$session order by osuser
select program Aplicacion, count(program) Numero_Sesiones from v$session group by program order by Numero_Sesiones desc
select username Usuario_Oracle, count(username) Numero_Sesiones from v$session group by username order by Numero_Sesiones desc
select owner, count(owner) Numero from dba_objects group by owner order by Numero desc
select * from dictionary
select *
select *
select * from user_tables
select * from user_catalog
Select t.tablespace_name "Tablespace", t.status "Estado", ROUND(MAX(d.bytes)/1024/1024,2) "MB Tamaño", ROUND((MAX(d.bytes)/1024/1024) - (SUM(decode(f.bytes, NULL,0, f.bytes))/1024/1024),2) "MB Usados", ROUND(SUM(decode(f.bytes, NULL,0, f.bytes))/1024/1024,2) "MB Libres", t.pct_increase "% incremento", SUBSTR(d.file_name,1,80) "Fichero de datos" FROM DBA_FREE_SPACE f, DBA_DATA_FILES d, DBA_TABLESPACES t WHERE t.tablespace_name = d.tablespace_name AND f.tablespace_name(+) = d.tablespace_name AND f.file_id(+) = d.file_id GROUP BY t.tablespace_name, d.file_name, t.pct_increase, t.status ORDER BY 1,3 DESC
select * from product_component_version
select * from role_sys_privs
select constraint_name, column_name
SELECT table_owner, table_name
SELECT DISTINCT TABLE_NAME FROM ALL_ALL_TABLES WHERE OWNER LIKE 'HR'
SELECT v.name, v.value value, decode(ISSYS_MODIFIABLE, 'DEFERRED', 'TRUE', 'FALSE') ISSYS_MODIFIABLE, decode(v.isDefault, 'TRUE', 'YES', 'FALSE', 'NO') "DEFAULT", DECODE(ISSES_MODIFIABLE, 'IMMEDIATE', 'YES','FALSE', 'NO', 'DEFERRED', 'NO', 'YES') SES_MODIFIABLE, DECODE(ISSYS_MODIFIABLE, 'IMMEDIATE', 'YES', 'FALSE', 'NO', 'DEFERRED', 'YES','YES') SYS_MODIFIABLE , v.description FROM V$PARAMETER v WHERE name not like 'nls%' ORDER BY 1
Select * FROM dba_users
select owner, decode(partition_name, null, segment_name, segment_name || ':' || partition_name) name, segment_type, tablespace_name,bytes,initial_extent, next_extent, PCT_INCREASE, extents, max_extents from dba_segments Where 1=1 And extents > 1 order by 9 desc, 3
select distinct vs.sql_text, vs.sharable_mem, vs.persistent_mem, vs.runtime_mem, vs.sorts, vs.executions, vs.parse_calls, vs.module, vs.buffer_gets, vs.disk_reads, vs.version_count, vs.users_opening, vs.loads, to_char(to_date(vs.first_load_time, 'YYYY-MM-DD/HH24:MI:SS'),'MM/DD HH24:MI:SS') first_load_time, rawtohex(vs.address) address, vs.hash_value hash_value , rows_processed , vs.command_type, vs.parsing_user_id , OPTIMIZER_MODE , au.USERNAME parseuser from v$sqlarea vs , all_users au where (parsing_user_id != 0) AND (au.user_id(+)=vs.parsing_user_id) and (executions >= 1) order by buffer_gets/executions desc
select * from V$DATAFILE
select * from V$TEMPFILE
select * from V$TABLESPACE
select * from V$BACKUP
select name,to_number(value) bytes from v$parameter where name ='shared_pool_size' union all select name,bytes from v$sgastat where pool = 'shared pool' and name = 'free memory'
select b.sid, a.username, b.value Cursores_Abiertos from v$session a, v$sesstat b, v$statname c where c.name in ('opened cursors current') and b.statistic# = c.statistic# and a.sid = b.sid and a.username is not null and b.value >0 order by 3
select sum(pins) Ejecuciones, sum(reloads) Fallos_cache, trunc(sum(reloads)/sum(pins)*100,2) Porcentaje_aciertos from v$librarycache where namespace in ('TABLE/PROCEDURE','SQL AREA','BODY','TRIGGER');
SELECT c.sid, d.piece, c.serial#, c.username, d.sql_text FROM v$session c, v$sqltext d WHERE c.sql_hash_value = d.hash_value and upper(d.sql_text) like '%WHERE CAMPO LIKE%' ORDER BY c.sid, d.piece
SELECT c.sid, d.piece, c.serial#, c.username, d.sql_text FROM v$session c, v$sqltext d WHERE c.sql_hash_value = d.hash_value and sid = 105 ORDER BY c.sid, d.piece
select sum(BYTES)/1024/1024 MB
select sum(bytes)/1024/1024 MB
select sum(bytes)/1024/1024 MB
select sum(bytes)/1024/1024 Table_Allocation_MB
select sum(vsize('NOMBRECOLUMNA'))/1024/1024 MB
SELECT owner, SUM(BYTES)/1024/1024
SELECT SEGMENT_TYPE, SUM(BYTES)/1024/1024
SELECT SEGMENT_NAME, SUM(BYTES)/1024/1024
SELECT distinct object_name FROM all_arguments WHERE package_name = 'STANDARD' order by object_name
select * from DBA_ROLES
select privilege from dba_sys_privs where grantee = 'NOMBRE_ROL'
select utl_inaddr.get_host_address IP from dual
select username, action_name, priv_used, returncode
select name, value Artículos relacionados
CréditosArtículo realizado íntegramente por Alonsojpd, miembro fundador del proyecto AjpdSoft. Nota: Revisado por AjpdSoft el 25-08-2009. Revisado por AjpdSoft el 16-08-2009. Revisado por AjpdSoft el 03-01-2009. Revisado por AjpdSoft el 17-11-2006. Anuncios
Enviado el Jueves, 19 mayo a las 13:31:04 por ajpdsoft
|
|