This document contains SQL queries to retrieve information about database objects, users, privileges, and settings. It includes queries to view tables, views, the database version, users, user privileges and roles, invalid objects, session parameters, and triggers. The queries are intended to analyze database configuration and permissions.
This document contains SQL queries to retrieve information about database objects, users, privileges, and settings. It includes queries to view tables, views, the database version, users, user privileges and roles, invalid objects, session parameters, and triggers. The queries are intended to analyze database configuration and permissions.
This document contains SQL queries to retrieve information about database objects, users, privileges, and settings. It includes queries to view tables, views, the database version, users, user privileges and roles, invalid objects, session parameters, and triggers. The queries are intended to analyze database configuration and permissions.
This document contains SQL queries to retrieve information about database objects, users, privileges, and settings. It includes queries to view tables, views, the database version, users, user privileges and roles, invalid objects, session parameters, and triggers. The queries are intended to analyze database configuration and permissions.
Download as TXT, PDF, TXT or read online from Scribd
Download as txt, pdf, or txt
You are on page 1of 2
-- Seleciona todas as tabelas de todos os owners
SELECT * FROM ALL_ALL_TABLES
--Caso seja necessrio especificar o owner que a tabela pertena: SELECT * FROM ALL_ALL_TABLES WHERE OWNER='NOME_OWNER' --Ver todas as VIEWS de usurio SELECT * FROM USER_VIEWS SELECT * FROM all_views -- VERIFICA INSTANCIA (IDENTIFICAR NOME DA INSTANCIA E INFORMAES DA MESMA) SELECT * FROM GLOBAL_NAME; SELECT * FROM V$INSTANCE; --VERSAO DO ORACLE (VERIFICAR QUAL A VERSAO DO ORACLE) SELECT VERSION FROM V$INSTANCE -- VERIFICAR QUAIS SO OS USURIOS DO SISTEMA (VERIFICAR TODOS OS USURIOS EXISTENTES) SELECT * FROM DBA_USERS -- CONTA OBJETOS DO SCHEMA (CONTA E LISTA TODOS OS TIPOS DE OBJETOS COM UM OWNER ESPECFICO) SELECT COUNT(OBJECT_TYPE), OBJECT_TYPE FROM DBA_OBJECTS WHERE OWNER LIKE 'RM%' GROUP BY OBJECT_TYPE; -- VERIFICA ATRIBUTOS DO USURIO (ATRIBUTOS GERAIS DE USURIOS) SELECT * FROM DBA_USERS WHERE USERNAME LIKE 'RM%'; SELECT * FROM DBA_TAB_PRIVS WHERE GRANTOR LIKE 'RM%'; -- VERIFICA PREVILEGIOS DO USURIO SELECT * FROM DBA_SYS_PRIVS WHERE GRANTEE LIKE 'RM%'; SELECT * FROM DBA_ROLE_PRIVS WHERE GRANTEE LIKE 'RM%'; -- DESATIVA USURIO / ATIVA ALTER USER USER RM ACCOUNT LOCK; ALTER USER USER RM ACCOUNT UNLOCK; ALTER USER USER RM PASSWORD EXPIRE; -- VERIFICA STATUS DA CONTA SELECT USERNAME, ACCOUNT_STATUS FROM DBA_USERS; -- VERIFICAR SE TEM ALGUM USURIO USANDO O SISTEMA (BOM CASO DESEJE PARAR O SERVIC O DO ORACLE SERVER) SELECT SADDR, SID, USERNAME, LOGON_TIME, STATUS, OSUSER, MACHINE, PROGRAM FROM V$SESSION; -- VERIFICA PREVILEGIOS DE ROLE SELECT * FROM DBA_ROLE_PRIVS; -- CONTA OBJETOS DO SCHEMA SELECT COUNT(OBJECT_TYPE), OBJECT_TYPE FROM DBA_OBJECTS GROUP BY OBJECT_TYPE;
-- CONTA OBJETOS DE UM SCHEMA ESPECFICO
SELECT COUNT(OBJECT_TYPE), OBJECT_TYPE FROM DBA_OBJECTS WHERE OWNER LIKE 'RM%' GROUP BY OBJECT_TYPE; -- CONTA OBJETOS INVALIDOS SELECT COUNT (*) FROM DBA_OBJECTS WHERE STATUS='INVALID' AND OWNER LIKE 'RM%'; -- VERIFICA OBJETOS INVALIDOS SELECT OBJECT_TYPE, OBJECT_NAME, STATUS FROM DBA_OBJECTS WHERE STATUS='INVALID' AND OWNER LIKE 'RM%'; -- GERA SCRIPTS DOS OBJETOS INVALIDOS SELECT 'ALTER'||' '|| OBJECT_TYPE ||' '||OWNER ||'.'|| OBJECT_NAME || ' COMPILE; ' FROM DBA_OBJECTS WHERE STATUS='INVALID' AND OWNER LIKE 'RM%'; -- VERIFICA AS ROLES RM SELECT * FROM DBA_ROLES WHERE ROLE LIKE '%RM%'; SELECT * FROM DBA_SYS_PRIVS WHERE LIKE '%RM%'; --ALTERAR SENHA DE USUARIO ALTER USER USER RM IDENTIFIED BY 'NOVA_SENHA'; --PROPRIEDADES DO SERVER (lANGUAGE, CHARACTER SET E ETC..) SELECT * FROM NLS_DATABASE_PARAMETERS; --PROPRIEDADES DA SESSAO (lANGUAGE, CHARACTER SET E ETC..) SELECT * FROM NLS_SESSION_PARAMETERS; --MOSTRA INFORMES GERAIS DA PARAMETRIZAO (NO FUNCIONA NO SQL TOOLS) SHOW PARAMETERS --VERIFICAR TRIGGERS NA BASE SELECT * FROM DBA_TRIGGERS WHERE TABLE_OWNER='RM';