List of Employees Name, Salary and Department Name
List of Employees Name, Salary and Department Name
List of Employees Name, Salary and Department Name
Diana Lorentz was transferred to Administration department. Using the employees and
department table information update the profile of employee.
Answer: UPDATE employees SET manager_id = 200, department_id = 10 WHERE last_name
= 'Lorentz' AND first_name = 'Diana';
Add a 500 pesos increase in salary of all employees who have rendered services 10 years and
above.
Answer: UPDATE employees SET salary = salary + 500 where TO_CHAR(sysdate,'YYYY') -
TO_CHAR(hire_date,'YYYY') >= 10
Update the Purchasing department name to Procurement. And this will be managed by the
Manager of Administration department.
Answer: UPDATE departments SET department_name = 'Procurement', manager_id = 200
WHERE department_name = 'Purchasing'
Display all the employee id, names of employees ,job id and department nameof all
employees of the Finance Department.
Answer: SELECT A.first_name, A.last_name, A.job_id, B.department_name FROM
employees A JOIN departments B ON ( A.department_id = B.department_id)
WHERE B.department_name = 'Finance'
Create a SQL command to add a new position Database Administrator with job id of
DB_ADMIN whose salary ranges from 10,000 to 18,000.
Answer: INSERT INTO jobs VALUES ('DB_ADMIN', 'Database Administrator', 10000,
18000)
Employee id : 200
Name : Mr. Gary Park
Date hired : July 1, 2017
Position :IT Programmer
Salary : 10000
Department of assignment : 60
Reporting to manager : 103
Answer: INSERT INTO employees
(employee_id,first_name,last_name,hire_date,job_id,salary,manager_id,department
_id)
VALUES (200,'Gary','Park', TO_CHAR('Jul 1, 2017', 'MON DD, YYYY'), 'IT_PROG',
10000, 103, 60)
Display the location id of all employee's name and salary whose salary is from 5000 to 10000.
Answer: SELECT first_name, last_name, salary FROM employees JOIN departments
USING (department_id) WHERE salary >= 5000 AND salary <= 10000
A new department name Training with department id 300 was created in the company.
This will be managed by a Manager with ID of 203 and will located at location id 2400.
Which of the following DOES NOT describes the state of the data after the COMMIT command
Answer: None of the choices
Given the DEPARTMENTS table and USER user1, evaluate the SQL command:
GRANT select
ON user1
TO departments;
Answer: The SQL command is incorrect
TRUE OR FALSE.
A FOREIGN KEY is a field in one table that refers to the PRIMARY KEY in another table.
Answer: True
Which of the following will grant a query privileges on the STUDENT table
Answer: GRANT select ON student TO matt
A join between two tables that returns the results of the INNER join as well as the_______________
rows from the left (or right) table is called a left (or right) OUTER join.
Answer: Unmatched
A _______________ consists of a collection of DML statements that form a logical unit of work.
Answer: Transaction
Which of the following describes the command below?
SELECT * FROM employees WHERE department = 60 FOR UPDATE
Answer: Locks the rows in the EMPLOYEES table with department id is 60.
Which of the following command will delete all records in the table employees
Answer: DELETE FROM employees
Which of the following will erase all records in the departments table
Answer: TRUNCATE TABLE departments
Angelica is the Oracle Database Administrator. She was been assigned to create an
access for the newly hired employee named Matt to the Oracle Database.
You want to cancel the privilege of matt to add records from the employees table.
Answer: REVOKE insert ON employees FROM matt;
TRUE OR FALSE.
Multiple fields in NOT allowed in a Foreign key.
Answer: False
These are privileges that performs a particular action within the database.
Answer: System Privileges
Nathaniel had accidentally deleted all the records in the newly updated ORACLE database
using the DELETE SQL command.
Answer: Run the ROLLBACK command
You want to cancel the privilege of matt to retrieve records from the employees table.
Answer: REVOKE select ON matt FROM employees;
This has the highest level of privileges for task such as creating new users, removing users and tables and
backing up tables.
Answer: DBA
A join between two tables that returns the results of an INNER join as well as the results of a
left and right join is
Answer: FULL OUTER JOIN
Which of the following PL/SQL will execute successfully?
Answer: DECLARE
v_salary INTEGER(20);
BEGIN
SELECT salary INTO v_salary FROM employees WHERE employee_id = 150;
END;
This is a type of cursor which is created and managed internally by the Oracle server to process
SQL statements
Answer: Implicit
You want to display all the records of employee the same with the salary employee number 103.
Answer: SELECT * FROM employees WHERE salary = (SELECT salary from employees where
employee_id= 103)
You have been tasked to update the database by creating a PL/SQL to increase the salary of all
IT Programmer employees by twice of their existing salary. Which of the following will execute
successfully?
Answer: DECLARE
v_job_id employees.job_id%TYPE := 'IT_PROG';
BEGIN
UPDATE employees SET salary = salary * 2 WHERE job_id = v_job_id;
END;
Which of the following PL/SQL that will display the total number employees whose salary is
10000 and above?
Answer: DECLARE
v_salary employees.salary%TYPE := 10000;
BEGIN
SELECT COUNT(*) INTO v_salary FROM employees WHERE salary >= v_salary;
DBMS_OUTPUT.PUT_LINE(v_salary);
END;
1. DECLARE
2. v_first_name VARCHAR2(50);
3. v_last_name VARCHAR2(50);
4. v_salary INTEGER(20);
5. BEGIN
6. SELECT first_name, last_name, salary INTO v_first_name, v_last_name, v_salary
FROM employees WHERE department_id = 60;
7. DBMS_OUTPUT.PUT_LINE('Firstname : '|| v_first_name);
8. DBMS_OUTPUT.PUT_LINE('Lastname : '|| v_last_name);
9. DBMS_OUTPUT.PUT_LINE('Salary : '|| v_salary);
10. END;
Answer: Error in Line 6.
You want to display all records in the database whose salary is above the salary of Alexander
Hunold.
Answer: SELECT * from employees WHERE salary < (SELECT salary FROM employees
WHERE first_name = 'Alexander' AND last_name = 'Hunold')
Actions are being performed when error occurs during PL/SQL execution in the
Answer: EXCEPTION
You have been tasked to update the database by creating a PL/SQL to increase the
salary of all IT Programmer employees by 50% of their existing salary.
1 DECLARE
2 v_employee_id employees.employee_id%TYPE := 114;
3 BEGIN
4 DELETE employees WHERE employee_id = v_employee_id;
5 END;
Answer: The PL/SQL will delete employee number 114.
Which of the following is INCORRECT?
Answer: Use single-row operators with multiple-row subqueries
ou want to display all employee id, name, hired date and salary who are hired after employee
104 was hired.
Answer: SELECT employee_id, last_name, hire_date, salary FROM employees WHERE
TO_NUMBER(TO_CHAR(hire_date, 'YYYY')) > (SELECT TO_NUMBER(TO_CHAR(hire_date,
'YYYY')) FROM employees WHERE employee_id = 104)
What is the error trapping function that returns the numeric value of the error code?
Answer: SQLCODE
You can use this procedure to issue user-defined error messages from stored subprograms.
Answer: RAISE_APPLICATION_ERROR
You can trap any error by including a corresponding handler within the exception-handling