EXAM QUESTIONS AND ANSWERS (UNIVERSITY OF SOUTH AFRICA)
SQL PRACTICE EXAM QUESTIONS AND ANSWERS
(UNIVERSITY OF SOUTH AFRICA)
INF3707 DATABASE DESIGN AND IMPLEMENTATION
1.
Q Examine the structure of the Debtors table:
Create table Debtors
(Customer# number primary key, First_name
varchar2(25), Last_name varchar2(25))
Create an SQL statement that inserts the following data into the Debtors table. The details of the debtor are as
follows: Debtor# is 201; First_name is William; Last_name is Jackson.
A INSERT INTO Debtors (Debtor#, First_name, Last_name)
2.
Q The Database Administrator wants to grant all users with query privileges on the Debtors1 table (see Question 1).
Write an SQL statement that accomplishes this?
A GRANT privileges SELECT ON
Debtors TO public;
3.
Q Write an SQL statement that would display the value 2090.55 as $2,090.55?
A Select FROM DUAL;
pg. 1
, SQL INF3707 DATABASE DESIGN AND IMPLEMENTATION PRACTICE
EXAM QUESTIONS AND ANSWERS (UNIVERSITY OF SOUTH AFRICA)
4.
Q Suppose the management of JustLee Books wants to compare the price of each book in the inventory against the
average price of all books in the inventory. Use an inline
subquery to show each price for prices that are above the average price of all the books.
A Select title, retail, retail (select TO_CHAR(avg(retail),99.9) from books) as diff From books;
5.
Q Examine the contents of the PUBLISHER table.
Write a query that lists only the last four digits of the contact person's phone number at Publish Our Way.
A SELECT SUBSTR (phone, -4, 4)
FROM publisher
WHERE name = 'PUBLISH OUR WAY';
pg. 2