Practica 03 Lección 03 Introducción a Oracle Server [OCADBA]
1.- Conéctese a la base de datos como usuario SYS y ciérrela.
SQL> CONNECT / AS SYSDBA Connected. SQL> SHUTDOWN IMMEDIATE Database closed. Database dismounted. ORACLE instance shut down.
2.- Con la base de datos cerrada, cree un archivo SPFILE a partir de PFILE. El archivo SPFILE se creará en $ORACLE_HOME/dbs
SQL> CONNECT / AS SYSDBA Connected to an idle instance. SQL> CREATE SPFILE FROM PFILE; File created.
3.- Desde el sistema operativo, visualice el archivo SPFILE.
—
4.- Conéctese como usuario SYS e inicie la base de datos con el archivo SPFILE.
SQL> CONNECT / AS SYSDBA Connected to an idle instance. SQL> STARTUP ORACLE instance started. Total System Global Area 26706720 bytes Fixed Size 729888 bytes Variable Size 20971520 bytes Database Buffers 4194304 bytes Redo Buffers 811008 bytes Database mounted.
5.-
a.- Cierre la base de datos y ábrala en modo de sólo lectura.
SQL> SHUTDOWN IMMEDIATE Database closed. Database dismounted. ORACLE instance shut down. SQL> STARTUP MOUNT Total System Global Area 26706720 bytes Fixed Size 729888 bytes Variable Size 20971520 bytes Database Buffers 4194304 bytes Redo Buffers 811008 bytes Database mounted. SQL> ALTER DATABASE OPEN READ ONLY; Database altered.
b.- Conéctese como usuario HR con la contraseña HR e inserte una fila en la tabla REGIONS , ¿Qué sucede?
/* Creado usuario */ SQL> CREATE USER HR IDENTIFIED BY HR; /* privilegios */ SQL> GRANT ALL PRIVILEGES TO HR; /* crear tabla regions */ SQL> CREATE TABLE regions ( id NUMBER, nombre VARCHAR2(50) ); SQL> CONNECT HR/HR Connected. SQL> INSERT INTO regions VALUES (5, 'Mars'); INSERT INTO regions VALUES (5, 'Mars') * ERROR at line 1: ORA-01552: cannot use system rollback segment for non-system tablespace 'SAMPLE'
c.- Vuelva a poner la base de datos en modo de lectura y escritura.
SQL> CONNECT / AS SYSDBA Connected. SQL> SHUTDOWN IMMEDIATE Database closed. Database dismounted. ORACLE instance shut down. SQL> STARTUP ORACLE instance started. Total System Global Area 26706720 bytes Fixed Size 729888 bytes Variable Size 20971520 bytes Database Buffers 4194304 bytes Redo Buffers 811008 bytes Database mounted. Database opened..
6.-
a.- Conéctese como usuario HR con la contraseña HR e inserte la siguiente fila en la tabla REGIONS; no valide ni salga de la base de datos.
INSERT INTO regions VALUES (5, ‘Mars’);
HR SESSION SQL> CONNECT HR/HR Connected. SQL> INSERT INTO regions VALUES (5, 'Mars'); 1 row created.
b.- En una nueva sesión telnet, inicie SQL*Plus. Conéctese como SYS y realice un SHUTDOWN TRANSACTIONAL.
SYS SESSION SQL> CONNECT / AS SYSDBA Connected. SQL> SHUTDOWN TRANSACTIONAL
c.- Realice un rollback de la inserción en la sesión HR y salga.
HR SESSION SQL> ROLLBACK; Rollback complete. SQL> EXIT; ERROR: ORA-01089: immediate shutdown in progress - no operations are permitted JServer Release 9.0.0.0.0 - Beta (with complications) Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Productn With the Partitioning, Oracle Label Security, OLAP and Oracle Data Mining optios JServer Release 9.2.0.1.0 - Production
¿Qué le ocurre a la sesión HR?
Se recibe un mensaje ORA-01089. El usuario HR no puede salir (EXIT) porque el usuario SYS ha emitido una sentencia SHUTDOWN TRANSACTIONAL. No se permite ninguna otra operación.
¿Qué le ocurre a la sesión SYS?
Cuando la sesión HR completa un ROLLBACK,la sesión SYS cierra la base de datos.
SYS SESSION Database closed. Database dismounted. ORACLE instance shut down.
La sesión HR se desconectará basándose en el comando EXIT.
HR SESSION Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Productn With the Partitioning, Oracle Label Security, OLAP and Oracle Data Mining optios JServer Release 9.2.0.1.0 - Production
7.-
a.- Inicie la base de datos en la sesión de usuario SYS.
SYS SESSION SQL> STARTUP ORACLE instance started. Total System Global Area 26706720 bytes Fixed Size 729888 bytes Variable Size 20971520 bytes Database Buffers 4194304 bytes Redo Buffers 811008 bytes Database mounted. Database opened.
b.- En la sesión telnet abierta, inicie SQL*Plus y conéctese como usuario HR.
Nota: Mantenga las dos sesiones SQL*Plus abiertas, una como usuario SYS y otra como usuario HR.
c.- Como usuario SYS, active una sesión restringida.
SYS SESSION SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION; System altered.
d.- Como usuario HR, realice un SELECT en la tabla REGIONS. ¿Se ha realizado la operación SELECT correctamente?
HR SESSION SQL> SELECT * FROM regions; REGION_ID REGION_NAME ---------- ------------------------- 1 Europe 2 Americas 3 Asia 4 Middle East and Africa
e.- Salga de la sesión y, a continuación, vuélvase a conectar como HR. ¿Qué sucede? El usuario HR no tiene el privilegio RESTRICTED SESSION y, por lo tanto, no puede conectarse.
HR SESSION SQL> EXIT Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Productn With the Partitioning, Oracle Label Security, OLAP and Oracle Data Mining optios JServer Release 9.2.0.1.0 - Production SQL> CONNECT HR/HR ERROR: ORA-01035: ORACLE only available to users with RESTRICTED SESSION privilege Warning: You are no longer connected to ORACLE.
f.- Como usuario SYS, desactive la sesión restringida.
SYS SESSION SQL> ALTER SYSTEM DISABLE RESTRICTED SESSION; System altered.
g.- Salga de la sesión telnet de HR
HR SESSION $ EXIT This session is no longer connected.