Sei sulla pagina 1di 4

1 What are the advantages of COMMIT and Rollback Statements?

Ensure data consistency


Preview data changes before making changes permanent.
Group logically-related operations.
2. What can Oracle Server Database Security do?
Control Database Access.
Give access to specific objects in the database.
Confirm given and received privileges with the Oracle data dictionary.
3. What is different between system privilege and object privilege?
System privilege: performing a particular action within the database.
Object privilege: manipulate the content of database objects.
4) Explain the statement as below
a) GRANT: provide the privilege to user
b) REVOKE: Remove privilege granted to User
c) COMMIT: Save
d) Rollback: Undo
5 What is different between single- row subquery and multiple row query?
single- row subquery:query that return only one row from the inner select statement
multiple row subquery: that return more than one row from the inner select statement.
6 Explain the operation as the fowling:
a)UNION:
b)UNION ALL
c) INTERSECT
d)MINUS
a)UNION:rows from both queries after eliminating duplications.
b) UNION ALL: rows from both queries including all duplications.
c) INTERSECT: rows that are common to both queries.
d) MINUS: rows in the first query that are not present in the second query.
6. What is different between HAVING and Where Clause?
Having clause :use with a conditiona with group function
Where Clause use with a condition neither group function.
7 Describe 5 constraints? 5pt
Primary Key: 1
Unique 1
NOT NULL
Foreign Key
Check
8 What is different between INITIALLY DEFERRED and INITIALLY IMMEDIATE ?
a) INITIALLY DEFERRED:waits to check the constraint until the transaction ends.
Page 1
b) INITIALLY IMMEDIATE: checks the constraint at the end of the statement execution.
9 What is different between SQL Statement and SQL PLUS Command?

SQL SQL*Plus
A language An environment
ANSI-standard Oracle proprietary
Keywords cannot be abbreviated Keywords can be abbreviated
Statements manipulate data and table Commands do not allow manipulation of
definitions in the database values in the database

10 What is Oracle SQL Developer?


Oracle SQL Developer is a graphical tool that enhances productivity and simplifies
database developments tasks.

12 What is data dictionary?


data dictionary is a collection of table and view in oracle database.
13. What command do you use to change your password?
ALTER USER STATEMENT
14. What privilege should a user be given to log on to the Oracle Server?
Is this a system privilege or an object privilege?
CREATE SESSION
SYSTEM PIVILEGE
6 what privilege should a user be given to create tables?
CREATE TABLE PRIVILEGE

15 You are the DBA. You are creating many users who require the same system privileges.
What should you use to make your job easier?
Create a role containing the system privileges and grant the role to the users.

Page 2
Part II: Display the information as below:
1. Display the employee last_name,job_id and start_date of employees hired between 2010
and 2014 order by start_date in a week and format as (Day the month of Year)
Answer:
SELECT LAST_NAME,JOB_ID,TO_CHAR(HIRE_DATE,'DD MONTH YYYY')
START_DATE FROM EMPLOYEES
WHERE TO_CHAR(HIRE_DATE,'YYYY')IN (2010,2014)

2. Write a query to display the last name, department number and department name for all
the employees who work in Toronto

SELECT e.last_name,e.job_id,e.department_id,d.department_name FROM


employees e JOIN departments d ON (e.department_id=d.department_id) JOIN location l
ON (d.location_id=l.location_id) WHERE LOWER(l.city)=toronto;
3. Display the employee number,last name and salary of all employees who earn more than
the average salary. Sort the result in order of ascending salary
SELECT employee_id,last_name,salary FROM employees
WHERE salary>(SELECT AVG(salary) FROM employees) ORDER BY salary;
4. Show all employees, and indicate with Yes or No whether they receive a
commission.
SELECT last_name,salary,decode(commission_pct,Null,'No','Yes')commission FROM
employees;

5. Create an anniversary overview based on the hire date of the employees. Sort the
anniversaries in ascending order.
Answer:
SELECT last_name,TO_CHAR(hire_date,Month DD) Birthday FROM employees
ORDER BY TO_CHAR(hire_date,DDD);
6. Show the name,salaries, and the number of dollar (in thousand) that all employees earn.
Answer:
SELECT last_name,salary,TRUNC(salary,-3)/1000 Thousands FROM employees;
7. Show all employees who have managers with a salary higher than $15,000.Showthe
following data: employee name,manager name, manager salary, and salary grade of the
manager.
Answer:
SELECT e.last_name,m.last_name manager,m.salary,j.grade_level
FROM employees e, employees m,job_grades j WHERE e.manager_id=m.employee_id AND
m.salary BETWEEN j.lowest_sal AND j.highest_sal AND m.salary>15000

8. Show all employees who were hired on the day of the week on which the highest number
of employees were hired.
9. SELECT last_name,TO_CHAR(hire_date,Day)Day FROM employees

Page 3
WHERE TO_CHAR(hire_date,Day)=(SELECT TO_CHAR(hire_date,Day)
HAVING COUNT(*)=(SELECT MAX(COUNT(*)) FROM Employees GROUP BY
TO_CHAR(hire_date,Day)))
10. Write a query to display the top three earners in the employees table. Display their last
names and salaries.
Answer:
SELECT last_name,salary FROM employees e WHERE 3>
(SELECT count(*) FROM employees WHERE e.salary<salary);
11. Write a query to display the last names,month of the date of join, and hire date of those
employees who have joined in the month of January,iresspective of the year of join.
SELECT last_name,EXTRACT(MONTH FROM HIRE_DATE),HIRE_DATE FROM
employees WHERE EXTRACT(MONTH FROM HIRE_DATE)=1
12. Display the employee number,last name, and salary of all employees who earn more than
the average salary. Sort the results in order of ascending salary.
SELECT employee_id,last_name,salary FROM employees WHERE salary>(SELECT
AVG(salary) FROM employees) ORDER By salary;
13. Display the last name,hire date, and day of the week on which the employee started.
Label the column as DAY. Order the results by the Day of the week, starting with
Monday.
SELECT last_name,hire_date,TO_CHAR(hire_date),DAY) DAY FROM employees
ORDER BY TO_CHAR(hire_date -1,d);

Page 4

Potrebbero piacerti anche