Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

‫جزء من أسئلة اختبار نهائي لمادة قواعد بيانات ‪ (1‬اوراكل ) ‪2021/2020‬‬

‫دكتور المادة محمد الزارعي‬


‫•‬
‫؏؏‬

‫لقد قمت بتجميع جزء من ما تذكرته من اختبار قواعد بيانات(اوراكل) للعام ‪ 2020‬وليس كامال‪.‬‬
‫الهدف مساعدتك لمعرفة مدى فهمك ومدى استعدادك لخوض االختبار وليس لحفظ جواب أسئلة النموذج‬
‫المادة بسيطة وممتعة ما عليك اال االستمتاع بمذاكرتها وحل اكثر جزء من التمارين‬
‫وهللا الموفق‬
‫‪Q1 i Create the DEPT table based on the following table instance chart .‬‬
‫‪Confirm that the table is created‬‬

‫‪ii Create the EMP table based on the following table instance chart.‬‬

‫‪Confirm that the table is created‬‬

‫‪- Add a column dept_id to EMP table‬‬

‫‪Add a table-level PRIMARY KEY constraint to the EMP table on the ID column‬‬
- Add a foreign key reference on the EMP2 table that ensures that the employee is not assigned to a

nonexistent department. Name the constraint my_emp_dept_id_fk.

Q2 Using the DECODE function and CASE ,

write a query that displays the grade of all employees based on the value of the JOB_ID column, using the
following data:
Q3 Create a report that displays a list of all employees whose salary is more than the salary of any employee
from department 60.

Q4 Create a report for the HR department that displays employee last names, department numbers, and all
employees who work in the same department as a given employee. Give each column an appropriate label

- Q6 - Show all employees who have managers with a salary higher than $15,000. Show the following
data: employee name, manager name, manager salary, and salary grade of the manager.

- Q7 - Create a view named DEPT80 that contains the employee numbers, employee last names, and
department numbers for all employees in department 80. They have requested that you label the view
columns EMPNO, EMPLOYEE, and DEPTNO. For security purposes, do not allow an employee to be
reassigned to another department through the view.

Q8 which section of a PL/SQL block is a user-defined exception raised?

A. exception handling B) executable

C) heading D) declarative

Answer: B

Q9 Evaluate this PL/SQL block: BEGIN


FOR i IN 1..10
LOOP IF i = 4 OR i = 6 THEN null;
ELSE
INSERT INTO test(results)
VALUES (I);
END IF;
COMMIT;
END LOOP;
ROLLBACK; END;
Q10 How many values will be inserted into the TEST table?

A) 4 B) 8 C.)0 D) 10 E) 6

Answer: B

Q11 Which should you do after each FETCH statement in a PL/SQL block?

A) Open the cursor. B) Initialize the loop.

C) Close the cursor. D) Test for rows using a cursor attribute

. Answer: D

Q12 Examine the declaration section


DECLARE
CURSOR emp_cursor(p_deptno NUMBER, p_job VARCHAR2)
IS
SELECT empno, ename FROM emp
WHERE deptno = p_deptno AND job = p_job; BEGIN
...
Which statement opens this cursor successfully?

A) OPEN emp_cursor('Clerk', 10); B) OPEN emp_cursor;

C) OPEN emp_cursor(p_deptno, p_job); D) OPEN emp_cursor(10,'Analyst');

Answer: D

Q13 You need to remove all the data from the employee table while leaving the table definition intact. You
want to be able to undo this operation. How would you accomplish this task?

A) TRUNCATE TABLE employee;

B) DELETE FROM employee;

C) This task cannot be accomplished.

D) DROP TABLE employee;

Answer: B
Q14 Given this executable section of a PL/SQL block:
BEGIN

FOR employee_record IN salary_cursor


LOOP
employee_id_table(employee_id) := employee_record.last_name;
END LOOP;
CLOSE salary_cursor;
END;
Why does this section cause an error?

A) The cursor does not need to be closed. B. No FETCH statements were issued.

C) Terminating conditions are missing. D) The cursor needs to be opened.

Answer: A

Q15 In which section of a PL/SQL block is a user-defined exception raised?

BEGIN

INSERT INTO EMP(Emp_ID, Lname, FName)

VALUES(‘1, ‘A’, ‘B’);

END;

‫ال أتذكر السؤال بالضبط اظن اإلجابة كانت‬


EMP_ID ‫ان‬

. ‘ ---- ‘ ‫ بداخل‬string ‫ يجب ان يكون‬. ’ -----‘ ‫ بداخل‬string ‫ ركز ان كان‬. ‫يجب ان ال يتكرر في الجدول‬

EMP_ID is the Primary key of regions table and therefore must be unique. EMP_ ID =1 may be already exists
in the table

Q16 Create a synonym for your EMPLOYEES table. Call it EMP1. Then find the names of all synonyms that are in
your schema
(CDB) ‫(و‬PDB) ‫لا أتذكر صيغة السؤال بالضبط كان يتحدث عن‬

Q17 how to startup container databases (CDB) and pluggable databases (PDB). ‫اظن السؤال كذا‬

How to open database ‫او ربما كذا‬

‫اظن انه كيف نفتح قواعد البيانات عندما تتغلف لان هذة المشكلة كانت تواجهنا في اغلب الاحيان‬

i manually

ii automatically by create trigger


‫لكن من خالل المطلوب واضح ماذا يقصد بالسؤال والجواب بسيط‬
‫الجواب‬

• manually

1- Check the status of the PDBs

sqlplus '/ as sysdba'

SQL> select name, open_mode from v$pdbs;

‫ موجودة او مركية معنا‬PDBs ‫هذا االمر لمعرفة أي‬

databasename

‫هنا نضع االسم الذي وضعناه نحن اثناء التثبيت والذي اسماها الدكتور‬

2- Start a PDB YEMENPDB

sqlplus '/ as sysbda'


‫اذا كنا ال نعرف اسمها نستخدم هذا االمر لمعرفة اسمها‬
SQL> alter pluggable database yemenpdb open; select name, open_mode from v$pdbs;

‫ فقط‬yemenpdb ‫في هذه الحالة سوف يفتخ قواعد البيانات‬ ‫ثم نستخدم هذا االمر‬

SQL> alter pluggable database all open;

• automatica by create trigger


‫اذا كنا نريد فتح الكل نستخدم هذا االمر‬
create or replace trigger OPEN_ALLPLUGGABLES
after startup
on database
begin
execute immediate 'alter pluggable databse all open';
end open_all_pdbs;
Q18 What's error then correct

Insert employee(fname,lname)
Set(‘A’,’B’);

Q19 Which of the following is true about PL/SQL package body?


A - The package body has the codes for various methods declared in the package specification and
other private declarations.
B - It is created using the CREATE PACKAGE Statement.
C - The codes, methods and types declared in package body are not hidden from code outside the
package.
D - All of the above.

Q20 Which of the following is true about PL/SQL package body?

1. The package body has methods declared in package specification and private.
2. It is created using the CREATE PACKAGE Statement.
3. Methods and types declared in package body are not hidden from code outside
4. All of the above.

Answer :1
Q21 The business hours for the video store are 8:00 AM through 10:00 PM,
Saturday through Wednesday
, and 8: 00 AM through 12: 00 AM on Friday. To ensure that the tables can be modified only during
these hours, create a stored procedure that is called by triggers on the tables.
a. Create a stored procedure called TIME_CHECK that checks the current time against business hours. If
the current time is not within business hours, use the RAISE_APPLICATION_ERROR procedure to
give an appropriate message.
b.
Create a trigger Fire the trigger before data is inserted, updated, and deleted from the tables. Call your
TIME_CHECK procedure from each of these triggers.

Q22 Write a function that converts currency from dollars $ to Yemeni riyals (RY)
Where 1$=500RY.

Q‫ذ‬23
‫طلب استدعاء الدالة وطباعة القيم التي تسترجعها الدالة بطريقتين مختلفتين‬
Q24
write a function (procedure) consisting of
i- RAISE_APPLICATION_ERROR
ii- PRAGMA EXCEPTION_INIT
iii- SQLCODE
iii- SQLERRM
.
.
.
..... ‫للاسئلة بقية‬


؏؏

‫ﻋﺒﺪﺍﻟﺮﺣﻤﻦﺍﻟﻐﺸﻴﻤ‬

You might also like