You are on page 1of 8

TECHNICAL

SUMMATIVE
ASSESSMENT 3

Submitted by Group 8

Ameliah Talimongan
John Paul Policarpio
Kimberly Anne Dimal
CCS0021 LABORATORY
TECHNICAL ASSESSMENT 3
Part A:

Write a series of scripts that would create a new user, grant at least four system and at least four object
privileges. Each script should have a comment statement what is statement is doing and its purpose.
Save the script as Tech9_fullname. Save this file as Tech3Document_fullname.

Write your answers below:

1. New User
--Create Table is a system privilege that enables the user to create own table for the database.
--Its purpose is to hold user data and to hold object instances of a particular type.
CREATE TABLE emp2
(empid NUMERIC (11) not null,
empName VARCHAR2(100));

2. Synonym
-- It is one of System privilege that enables a user to create a private synonym on a given data.
--Its purpose is grant users access to an item owned by another schema but don't want them to
know which schema owns the object.
CREATE SYNONYM Emp1 FOR emp2;

3. View
--Create is also one of System privilege that allows a user to build a view in her/his table.
--The purpose of this is update the data in the view's underlying tables.
CREATE VIEW Emp1_dt AS
SELECT empid, empName FROM Emp1;

4. Session
--One of the System Privilege that enables user to create a connection to the database.
--its purpose is to grant user to have a connection to the database.
CREATE USER pip6x IDENTIFIED BY myPassword06;
GRANT CONNECT TO pip6x;
GRANT CREATE SESSION TO pip6x;

5. Delete
--Delete is one of the Object privilege that allows user to delete from the table.
--Its purpose is to removes all rows of data from a table or view that is specified.
DELETE FROM Emp1 WHERE empName = 'Jackson';
6. Insert
--Insert is also an Object privilege that allows a user to enter into a table directly or via a synonym.
--its purpose is to insert new data rows into a table.
INSERT INTO Emp1 (empid, empName) Values (1, 'Jackson');

7. Index
--One of the Object privileges that creates an index on a table or materialized view for the user.
--The purpose of this is to enable faster data access for procedures that only return a small number
of rows from a table.
CREATE INDEX empid_l ON Emp1(empid);

Part B:

Answer the following using SQL developer. Use the schema of HR to answer this. Copy and paste your
answer below each number. And also paste the result of your answers.

Save the sql script as TechSumm10_fullname

1. Create a sequence that starts with 1, an interval of 2 and the biggest number is 999999. Name the
sequence as Sequence1.

Create Sequence Sequence1 Start with 1

Increment by 2 Maxvalue 999999

nocache nocycle;
2. Create a view that will show all the salaries and names of employees in the Administration
department.

Create View Addept as Select e.Salary, e.First_name, e.Last_name,

d.Department_name From Employees e Inner Join Departments d On

e.Department_id = d.Department_id Where d.Department_name = 'Administrati on'

3. Create a synonym of the job_history table. Name the synonym as JHistory.

Create Synonym JHistory For Job_History;


4. Create an anonymous block that would output your complete name of the screen.

BEGIN Dbms_output.Put_line('Jeremie Calinisan'); END;

5. Create an anonymous block to get the average of 5 numbers. Each number should come from the
input of the user.

DECLARE
n1 NUMBER;
n2 NUMBER;
n3 NUMBER;
n4 NUMBER;
n5 NUMBER;
Ave NUMBER;
BEGIN n1:=&n1;
n2:=&n2;
n3:=&n3;
n4:=&n4;
n5:=&n5;
Ave:=(n1+n2+n3+n4+n5)/2;
Dbms_output.Put_line('The Average is: ' || Ave);
END;
/
6. Create an anonymous block that will input the name of an employee, birthday, address and age. The
name of the employee, birthday and address should come from the input of the user, while the age
should be calculated based on his/her birthday.

DECLARE
Dob DATE;
Age NUMBER(3, 1);
Ename VARCHAR2(100);
Addr VARCHAR2(150);
BEGIN Ename:='&Name';
Addr:='&Address';
Dob:= to_date('&Date', 'MM/DD/YYYY');
Age := TRUNC(MONTHS_BETWEEN(SYSDATE, Dob))/12;
DBMS_OUTPUT.PUT_LINE ('Name is: '|| Ename);
DBMS_OUTPUT.PUT_LINE ('Address is: ' || Addr);
DBMS_OUTPUT.PUT_LINE ('Date of Birth is: ' || Dob);
DBMS_OUTPUT.PUT_LINE ('Your age is ' || Age); END; /
Part C:

Given the question below:

Save your scripts as Tech11_fullname

Write your answers below:

A. The Value is 2 and The Data type is NUMBER.

B. The Value is Western Europe and The Data Type is VARCHAR2.

C. The Value is 601 and The Data Type is NUMBER.

D. The Value is Product 10012 is in stock and The Data Type is VARCHAR2.

E. It is illegal because v_new_locn is not visible outside the subblock

You might also like