Model exam 2 on ch. 8, 9, 10

advertisement
‫بسم هللا الرحمن الرحيم‬
Kingdom of Saudi Arabia
Ministry of Higher Education
Majmaah University
College Of Sciences in Alzulfi
Second exam ‫ السادس‬-:‫المستوى‬
CIS326 -:‫رقم ورمز المادة‬
1436/2/25 -:‫تاريخ اإلمتحان‬
-:‫الرقم الجامعي‬
‫الـمـمـلكـة الـعـربـيـة الـسـعـوديـة‬
‫وزارة الـتـعـلـيـم الـعـالـي‬
‫جـامـعـة الـمـجـمـعـة‬
‫كلية العلوم بالزلفي‬
2 ‫قواعد البيانات‬
-:‫اسم المادة‬
-:‫اسم الطالب‬
Question 1:
For table shown in Fig. 1 write the SQL statements to do the following:
EmployeeID LastName FirstName BirthDate
salary
1
Davolio
Nancy
1968-12-08
2000
2
Leverling
Janet
1963-08-30
3000
3
Peacock
Margaret
1958-09-19
1500
4
Buchanan
Steven
1955-03-04
2500
5
Suyama
Michael
1963-07-02
3600
6
King
Robert
1960-05-29
1000
Fig. 1 Employee table
a- Add the row of data in the Employee table from the
(7
Fuller
Andrew 1952-02-19
6500)
Ans. SQL> Insert into Employee
Values(7 Fuller
Andrew 1952-02-19
6500);
b- change the last name of employee 3 to Motery.
Ans. SQL> UPDATE Employee
Set lastname='Motery'
Where employeeid=3;
c- change the salary to 3000 for all employees with a salary less
than 2000.
Ans. SQL> update employee
Set salary =3000
Where salary<2000
1
Kingdom of Saudi Arabia
‫بسم هللا الرحمن الرحيم‬
‫الـمـمـلكـة الـعـربـيـة الـسـعـوديـة‬
‫وزارة الـتـعـلـيـم الـعـالـي‬
‫جـامـعـة الـمـجـمـعـة‬
‫كلية العلوم بالزلفي‬
Ministry of Higher Education
Majmaah University
College Of Sciences in Alzulfi
Second exam ‫ السادس‬-:‫المستوى‬
CIS326 -:‫رقم ورمز المادة‬
1436/2/25 -:‫تاريخ اإلمتحان‬
-:‫الرقم الجامعي‬
2 ‫قواعد البيانات‬
-:‫اسم المادة‬
-:‫اسم الطالب‬
Question 2:
Write statements to execute the following actions:
a. create a new user Ali
Ans. create user Ali
Identified by xx;
b. Give the user Ali grant privilege to create table and view.
Ans. SQL> Grant create table, create view
2 to Ali;
c. Create and Granting privileges to role manager to create table
and view and assign role to users Ali and Ahmed.
Ans.
SQL> Create role manager;
SQL> Grant create table, create view
2 to manager;
SQL>Grant manager to Ali, Ahmed;
d. Give the user Ali grant privilege to modify Firstname and
salary columns in employee table in Fig. 1
Ans.
SQL> Grant Update(Firstname, salary)
2 ON employee
3 TO Ali;
2
Kingdom of Saudi Arabia
‫بسم هللا الرحمن الرحيم‬
Ministry of Higher Education
Majmaah University
College Of Sciences in Alzulfi
Second exam ‫ السادس‬-:‫المستوى‬
CIS326 -:‫رقم ورمز المادة‬
1436/2/25 -:‫تاريخ اإلمتحان‬
-:‫الرقم الجامعي‬
‫الـمـمـلكـة الـعـربـيـة الـسـعـوديـة‬
‫وزارة الـتـعـلـيـم الـعـالـي‬
‫جـامـعـة الـمـجـمـعـة‬
‫كلية العلوم بالزلفي‬
2 ‫قواعد البيانات‬
Question 3:
Consider the following SQL statements:
SQL> select * from scott.test;
no rows selected
SQL> insert into scott.test values (1, 2)
2 savepoint trans_1
3 insert into scott.test values (3, 4)
4 savepoint trans_2
5 insert into scott.test values (5, 6)
6 rollback to trans_1
7 select * from scott.test;
a. Name of user__scott_______ name of table __test_____
b. Draw the result table.
Ans.
AB
——
12
c. Rewrite statements to make all modifications permanent.
Ans.
SQL> insert into scott.test values (1, 2)
2 insert into scott.test values (3, 4)
3 insert into scott.test values (5, 6)
4 commit;
3
-:‫اسم المادة‬
-:‫اسم الطالب‬
Download