Вы находитесь на странице: 1из 5

Laboratrio

Administrao de Usurios
SQL> create user aluno identified by aluno;
User created.
SQL> conn aluno
Enter password:
ERROR:
ORA-01045: user ALUNO lacks CREATE SESSION privilege; logon denied
Warning: You are no longer connected to ORACLE.
SQL>
SQL> conn sys as sysdba
Enter password:
Connected.
SQL>
SQL> grant connect to aluno;
Grant succeeded.
SQL> conn aluno/aluno;
Connected.
SQL> select * from dual;
D
X
Quais so os privilgios que esse usurio possui? PUBLIC
SQL> shutdown immediate;
ORA-01031: insufficient privileges
SQL> conn sys as sysdba
Enter password:
Connected.
SQL> grant dba to aluno;
Grant succeeded.
SQL> shutdown immediate;

Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 64bit Production
[root@localhost ~]# sqlplus aluno/aluno
SQL*Plus: Release 11.2.0.2.0 Production on Mon Oct 13 23:11:51 2014
Copyright (c) 1982, 2011, Oracle.

All rights reserved.

ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Process ID: 0
Session ID: 0 Serial number: 0
[root@localhost ~]# sqlplus sys as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Mon Oct 13 23:15:30 2014
Copyright (c) 1982, 2011, Oracle.

All rights reserved.

Enter password:
Connected to an idle instance.
SQL> startup;
ORACLE instance started.
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers
Database mounted.
Database opened.

839282688
2231136
507511968
327155712
2383872

SQL> grant sysdba to aluno;


Grant succeeded.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit

bytes
bytes
bytes
bytes
bytes

Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 64bit Production
[root@localhost ~]#
[root@localhost ~]# sqlplus aluno/aluno
SQL*Plus: Release 11.2.0.2.0 Production on Mon Oct 13 23:19:38 2014
Copyright (c) 1982, 2011, Oracle.

All rights reserved.

ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Process ID: 0
Session ID: 0 Serial number: 0
Por que o erro aconteceu? Quando no se usa a clausula SYSDBA, o Oracle no verifica o
password file.
Enter user-name: aluno as sysdba
Enter password:
Connected to an idle instance.

Administrao de Perfis
SQL> create role r_select;
Role created.
SQL> create table tabela_1 as select * from dual;
Table created.
SQL> grant connect to r_select;
Grant succeeded.
SQL> grant select on tabela_1 to r_select;
Grant succeeded.
SQL> create user aluno2 identified by aluno2;
User created.
SQL> grant r_select to aluno2;
Grant succeeded.
SQL> conn aluno2/aluno2
Connected.

SQL> select * from aluno.tabela_1;


D
X
Como fao para dar permisso de leitura para todos os usurios? PUBLIC.

Auditoria Padro do Banco de Dados


Auditoria Mandatria:
SQL> show parameter audit
NAME
-----------------------------------audit_file_dest
audit_sys_operations
audit_syslog_level
audit_trail

TYPE
VALUE
----------- -----------------------------string
/u01/app/oracle/admin/XE/adump
boolean
FALSE
string
string
NONE

SQL> quit
Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit
Production
[root@localhost ~]# sqlplus sys as sysdba;
[root@localhost ~]# cd /u01/app/oracle/admin/XE/adump/
VERIFICAR ARQUIVO DE AUDITORIA GERADO.

Ligando a auditoria Padro do Banco de Dados


SQL> alter system set audit_trail=DB scope=spfile; //So fara efeito apos o restart do
Banco
System altered.
SQL> audit table by hr;
Audit succeeded.
SQL> select * from hr.departments;
SQL> select ses_actions, action_name from dba_audit_trail where obj_name = 'DEPARTMENTS';
SES_ACTIONS
ACTION_NAME
------------------- ----------------------------

---------S--------------S------

SESSION REC
SESSION REC

SQL> select * from hr.departments where 1=2;


no rows selected
SQL>

select ses_actions, action_name from dba_audit_trail where obj_name = 'DEPARTMENTS';

SES_ACTIONS
---------------------------S--------------S--------------S------

ACTION_NAME
---------------------------SESSION REC
SESSION REC
SESSION REC