Roteiro Lab 1
-
Upload
diego-akechi -
Category
Documents
-
view
215 -
download
0
description
Transcript of Roteiro Lab 1
Laboratório
Administração de Usuários
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 são os privilégios que esse usuário possui? PUBLIC
SQL> shutdown immediate;ORA-01031: insufficient privileges
SQL> conn sys as sysdbaEnter password: Connected.SQL> grant dba to aluno;
Grant succeeded.
SQL> shutdown immediate;
Database closed.Database dismounted.ORACLE instance shut down.
SQL> exitDisconnected 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 availableORA-27101: shared memory realm does not existLinux-x86_64 Error: 2: No such file or directoryProcess ID: 0Session 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 839282688 bytesFixed Size 2231136 bytesVariable Size 507511968 bytesDatabase Buffers 327155712 bytesRedo Buffers 2383872 bytesDatabase mounted.Database opened.
SQL> grant sysdba 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 ~]# [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 availableORA-27101: shared memory realm does not existLinux-x86_64 Error: 2: No such file or directoryProcess ID: 0Session ID: 0 Serial number: 0
Por que o erro aconteceu? Quando não se usa a clausula SYSDBA, o Oracle não verifica o password file.
Enter user-name: aluno as sysdbaEnter password: Connected to an idle instance.
Administração 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/aluno2Connected.
SQL> select * from aluno.tabela_1;
D-X
Como faço para dar permissão de leitura para todos os usuários? PUBLIC.
Auditoria Padrão do Banco de Dados
Auditoria Mandatória:
SQL> show parameter audit
NAME TYPE VALUE------------------------------------ ----------- ------------------------------audit_file_dest string /u01/app/oracle/admin/XE/adumpaudit_sys_operations boolean FALSEaudit_syslog_level stringaudit_trail string NONE
SQL> quitDisconnected 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 Padrão 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------ SESSION REC---------S------ 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 ACTION_NAME------------------- -------------------------------------S------ SESSION REC---------S------ SESSION REC---------S------ SESSION REC