You are on page 1of 5

JOSE ALONSO MEDINA DONAYRE

PREGUNTA 1:
CREATE USER parcial identified by parcial;

ALTER USER parcial DEFAULT TABLESPACE Parcial_data_tbs01 QUOTA UNLIMITED ON


Parcial_data_tbs01;

GRANT CREATE SESSION TO PARCIAL;


GRANT CREATE ANY INDEX TO PARCIAL;

GRANT SELECT, INSERT ON CLIENTE TO PARCIAL;


GRANT SELECT, INSERT ON RESERVA TO PARCIAL;
GRANT SELECT, INSERT ON DETALLE_RESERVA TO PARCIAL;

CREATE ROLE EXPARCIAL;

GRANT CREATE TABLE TO EXPARCIAL;

GRANT EXPARCIAL TO PARCIAL;

--------------------------------------------------------------

PREGUNTA 2:

mkdir -p /u02/Oracle/data

chmod -R 7777 /u02/Oracle/data

mkdir -p /u03/Oracle/indice

chmod -R 7777 /u03/Oracle/indice

CREATE TABLESPACE Parcial_data_tbs01 datafile '/u02/Oracle/data/parcial01.dbf' SIZE 625M;

CREATE TABLESPACE Parcial_index_tbs datafile '/u03/Oracle/indice/indices01.dbf' SIZE 135M;

--------------------------------------------------------------

PREGUNTA 3:

SISTEMA DE RESERVA DE PASAJES DE VIAJE

CONNECT PARCIAL;

CREATE TABLE CLIENTE (ID_CLIENTE VARCHAR(5),NOMBRE VARCHAR(20) NOT NULL,


APE_PATERNO VARCHAR(20) NOT NULL, APE_MATERNO VARCHAR(20), DNI VARCHAR(8) UNIQUE,
TELEFONO VARCHAR(9), CONSTRAINT PK_CLIENTE PRIMARY KEY (ID_CLIENTE)) TABLESPACE
Parcial_data_tbs01;

CREATE TABLE RESERVA(ID_RESERVA VARCHAR(5),ID_CLIENTE VARCHAR(5), FECHA_RESERVA


DATE NOT NULL, FECHA_VIAJE DATE NOT NULL, DESTINO VARCHAR(20) NOT NULL,
MONTO_TOTAL NUMBER(10,2) NOT NULL, CONSTRAINT PK_RESERVA PRIMARY KEY
(ID_RESERVA), CONSTRAINT FK_RESERVA_CLIENTE FOREIGN KEY(ID_CLIENTE) REFERENCES
CLIENTE(ID_CLIENTE) ) TABLESPACE Parcial_data_tbs01;

CREATE TABLE DETALLE_RESERVA (ID_DETALLE VARCHAR(5),ID_RESERVA VARCHAR(5),


ID_CLIENTE VARCHAR(5),SERVICIO VARCHAR(30) NOT NULL,PRECIO_UNITARIO NUMBER(10,2)
NOT NULL, CONSTRAINT PK_RESERVA_DETALLE PRIMARY KEY(ID_DETALLE, ID_RESERVA,
ID_CLIENTE), CONSTRAINT FK_DET_RES_CLIENTE FOREIGN KEY (ID_CLIENTE) REFERENCES
CLIENTE(ID_CLIENTE),CONSTRAINT FK_DET_RES_RESERVA FOREIGN KEY (ID_RESERVA)
REFERENCES RESERVA(ID_RESERVA)) TABLESPACE Parcial_data_tbs01;

INSERT INTO CLIENTE VALUES ('C0001','JOSE','MEDINA', 'DONAYRE', '72207303', '942851494');


INSERT INTO CLIENTE VALUES ('C0002','PEDRO','PALAO', 'ENRI', '72202203', '942833494');
INSERT INTO CLIENTE VALUES ('C0003','MARIA','ISRAEL', 'ESTEFANOSKI', '72117303', '944451494');
INSERT INTO CLIENTE VALUES ('C0004','ERNESTO','JUDAS', 'LOPEZ', '72227303', '942855494');
INSERT INTO CLIENTE VALUES ('C0005','RAFAEL','SANTORO', 'GAMARRA', '72233303',
'966851494');

INSERT INTO RESERVA VALUES ('R0005','C0001','22/11/2018', '22/03/2019','CANCUN',1500);


INSERT INTO RESERVA VALUES ('R0001','C0002','3/11/2018', '22/11/2018', 'ISLAS
BALLESTAS',2000);
INSERT INTO RESERVA VALUES ('R0002','C0001','22/05/2018', '12/08/2018', 'PLUTON',3200);
INSERT INTO RESERVA VALUES ('R0003','C0003','22/12/2018', '13/05/2019', 'MARTE',2000);
INSERT INTO RESERVA VALUES ('R0004','C0005','22/11/2019', '02/02/2019', 'ESPAÑA',1200);

INSERT INTO DETALLE_RESERVA VALUES ('00001','R0005','C0001','ALL DAY',1500);


INSERT INTO DETALLE_RESERVA VALUES ('00001','R0001','C0002','FULL TOUR',2000);
INSERT INTO DETALLE_RESERVA VALUES ('00001','R0002','C0001','MID TOUR',3200);
INSERT INTO DETALLE_RESERVA VALUES ('00001','R0003','C0003','ALL INCLUDED',2000);
INSERT INTO DETALLE_RESERVA VALUES ('00001','R0004','C0005','FULL VACATIONS',1500);

------------------------------------------------------------------
PREGUNTA 4:

MUESTRA LOS PASAJES DE JOSE JUNTO CON EL SERVICIO ADQUIRIDO POR CADA PASAJE

SELECT C.NOMBRE AS NOMBRE, C.APE_PATERNO AS PATERNO, C.APE_MATERNO AS MATERNO,


TO_CHAR(B.FECHA_VIAJE,'DD/MM/YYYY') AS FECHA_VIAJE, B.DESTINO AS DESTINO, A.SERVICIO
AS SERVICIO, A.PRECIO_UNITARIO AS PRECIO FROM CLIENTE C INNER JOIN RESERVA B ON
C.ID_CLIENTE = B.ID_CLIENTE INNER JOIN DETALLE_RESERVA A ON A.ID_CLIENTE = C.ID_CLIENTE
AND A.ID_RESERVA = B.ID_RESERVA WHERE C.ID_CLIENTE = 'C0001';
------------------------------------------------------------------
PREGUNTA 5:

REVOKE CREATE SESSION FROM PARCIAL;


REVOKE CREATE ANY INDEX FROM PARCIAL;

REVOKE SELECT, INSERT ON CLIENTE FROM PARCIAL;


REVOKE SELECT, INSERT ON RESERVA FROM PARCIAL;
REVOKE SELECT, INSERT ON DETALLE_RESERVA FROM PARCIAL;

REVOKE CREATE TABLE FROM EXPARCIAL;

REVOKE EXPARCIAL FROM PARCIAL;

DROP ROLE EXPARCIAL;


DROP USER PARCIAL;

ADICIONALES

SELECT * FROM ROLE_SYS_PRIVS Privilegios de sistema otorgados a roles


SELECT * FROM ROLE_TAB_PRIVS Privilegios de tabla otorgados a roles
SELECT * FROM USER_ROLE_PRIVS Roles accesibles por usuario.
SELECT * FROM USER_SYS_PRIVS Privilegios de sistema otorgados al usuario.
SELECT * FROM USER_TAB_PRIVS_MADE Privilegios otorgados en los objetos del usuario.
SELECT * FROM USER_TAB_PRIVS_RECD Privilegios de objetos otorgados al usuario.
SELECT * FROM USER_COL_PRIVS_MADE Privilegios otorgados en las columnas de los
objetos de usuario.
SELECT * FROM USER_COL_PRIVS_RECD Privilegios de objetos otorgados al usuario en
columnas específicas.
Select * from dba_sys_privs
Select * from dba_col_privs

DAR ESPACIO LIMITADO EN TABLESPACE

(CREATE/ALTER) USER parcial


DEFAULT TABLESPACE Parcial_data_tbs01
TEMPORARY TABLESPACE TEMP
QUOTA (UNLIMITED/45M) ON Parcial_data_tbs01;

GRANT UNLIMITED TABLESPACE TO ALONSO

GRANT create any index TO galloso;


GRANT create user TO galloso;
GRANT create any index TO galloso WITH ADMIN OPTION;
ALTER ANY INDEX TO ALONSO
ALTER ANY ROLE TO ALONSO
DROP USER user [CASCADE];

CREATE PROFILE prof LIMIT


FAILED_LOGIN_ATTEMPTS 10
PASSWORD_LOCK_TIME 30;

ALTER USER johndoe PROFILE prof;


ALTER USER johndoe ACCOUNT UNLOCK;

Crear el Perfil con nombre perfil:

CREATE PROFILE perfil LIMIT


SESSIONS_PER_USER 2
CPU_PER_SESSION unlimited
CPU_PER_CALL 5000
LOGICAL_READS_PER_SESSION unlimited
LOGICAL_READS_PER_CALL 100
IDLE_TIME 30
CONNECT_TIME 480;

DROP PROFILE perfil CASCADE;

Para obtener información acerca de los perfiles se utilizan las vistas del sistema:

SELECT USERNAME, PROFILE, ACCOUNT_STATUS FROM DBA_USERS;


SELECT * FROM USER_RESOURCE_LIMITS;
SELECT * FROM DBA_PROFILES
ALTER PROFILE perfil LIMIT
FAILED_LOGIN_ATTEMPTS 4
PASSWORD_LOCK_TIME 30;