Oracle 1Z0-051 - Estudo Dirigido: Name Null Type

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

Oracle 1Z0-051 – Estudo dirigido

1. Assume the tables EMPLOYEES and DEPARTMENT have to be joined using NATURAL JOIN. What is
the difference between the following two queries which follow? (Consider the table structures as given)
SQL> DESC employees
Name Null? Type
----------------------- -------- ----------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)

SQL> DESC departments


Name Null? Type
----------------------- -------- ----------------
DEPARTMENT_ID NOT NULL NUMBER(4)
DEPARTMENT_NAME NOT NULL VARCHAR2(30)
MANAGER_ID NUMBER(6)
LOCATION_ID NUMBER(4)

SELECT *
FROM employees NATURAL JOIN departments
WHERE first_name = 'William'
AND last_name = 'Gietz';

SELECT *
FROM employees INNER JOIN departments
ON employees.DEPARTMENT_ID = departments.DEPARTMENT_ID
AND employees.MANAGER_ID = departments.MANAGER_ID
WHERE first_name = 'William'
AND last_name = 'Gietz';

A. There is no difference
B. The result is different in both the cases
C. Both the queries will give an ORA error on execution
D. None of the above

2. What will the outcome of the following query?


SELECT NVL (NULL,'1') FROM dual;

A. NULL
B. 1
C. 0
D. Gives an error because NULL cannot be explicitly specified to NVL function

ESTUDO DIRIGIDO – FICHA 01 Página 1 de 21


Oracle 1Z0-051 – Estudo dirigido
3. Which of the below queries will format a value 1680 as $16,80.00?
A. SELECT TO_CHAR(1680.00,'$99G99D99') FROM dual;
B. SELECT TO_CHAR(1680.00,'$9,999V99') FROM dual;
C. SELECT TO_CHAR(1680.00,'$9,999D99') FROM dual;
D. SELECT TO_CHAR(1680.00,'$99G999D99') FROM dual;

4. Which of the following statements is true regarding the COUNT function?


A. COUNT (*) counts duplicate values and NULL values in columns of any data type.
B. COUNT function cannot work with DATE datatypes.
C. COUNT (DISTINCT job_id) returns the number of rows excluding rows containing duplicates and NULL
values in the job_id column.
D. A SELECT statement using the COUNT function with a DISTINCT keyword cannot have a WHERE clause.

5. Determine the output of the below query.


SELECT RPAD(ROUND('78945.45'),10,'*') FROM dual;

A. 78945*****
B. **78945.45
C. The function RPAD cannot be nested with other functions
D. 78945.45****

6. Examine the structure of the EMPLOYEES table as given.


SQL> DESC employees
Name Null? Type
----------------------- -------- ----------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)

What will be the outcome of the following query?

SELECT last_name, NVL(job_id, 'Unknown')


FROM employees
WHERE last_name LIKE 'A%'
ORDER BY last_name;

A. It will throw an ORA error on execution.


B. It will list the job IDs for all employees from EMPLOYEES table.
C. It will list the job IDs of all employees and substitute NULL job IDs with a literal 'Unknown'.
D. It will display the last names for all the employees and their job IDs including the NULL values in the job ID.

ESTUDO DIRIGIDO – FICHA 01 Página 2 de 21


Oracle 1Z0-051 – Estudo dirigido
7. You need to display the country name from the COUNTRIES table. The length of the country name
should be greater than 5 characters. Which of the following queries will give the required output?
A. SELECT country_name FROM countries WHERE LENGTH (country_name)= 5;
B. SELECT country_name FROM countries WHERE length (country_name)> 5;
C. SELECT SUBSTR(country_name, 1,5) FROM countries WHERE length (country_name)<
5;
D. SELECT country_name FROM countries WHERE length (country_name) <> 5;

8. Which of the following functions are used to differentiate between even or odd numbers in Oracle DB?
A. ROUND
B. TRUNC
C. MOD
D. REPLACE

9. Which of the following is true for the statement given as under.


NVL2 (arg1, arg2, arg3)

A. Arg2 and Arg3 can have any data type


B. Arg1 cannot have the LONG data type
C. Oracle will convert the data type of expr2 according to Arg1
D. If Arg2 is a NUMBER, then Oracle determines the numeric precedence, implicitly converts the other
argument to that datatype, and returns that datatype.

Examine the structure of the EMPLOYEES table as given and answer the questions 10 to 12 that follow.
SQL> DESC employees
Name Null? Type
----------------------- -------- ----------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)

10. Which of the following queries will give the same result as given in the query given below?
SELECT CONCAT(first_name, last_name) FROM employees;

A. SELECT first_name || last_name FROM employees;


B. SELECT first_name || ' ' || last_name FROM employees;
C. SELECT last_name || ', ' ||first_name FROM employees;
D. SELECT first_name || ',' || last_name FROM employees;.

ESTUDO DIRIGIDO – FICHA 01 Página 3 de 21


Oracle 1Z0-051 – Estudo dirigido
11. What will be the outcome of the following query?
SELECT 'The job id for '||upper(last_name) ||' is a '||lower(job_id) FROM
employees;

A. The job id for ABEL is a sa_rep


B. The job id for Abel is a Sa_rep
C. The job id for abel is SA_REP
D. The job id for abel is sa_rep;

12. Assuming the last names of the employees are in a proper case in the table employees, what will be the
outcome of the following query?
SELECT employee_id, last_name, department_id FROM employees WHERE last_name =
'smith';

A. It will display the details of the employee with the last name as Smith
B. It will give no result.
C. It will give the details for the employee having the last name as 'Smith' in all Lower case.
D. It will give the details for the employee having the last name as 'Smith' in all INITCAP case.

13. Examine the structure of the EMPLOYEES table as given here.


SQL> DESC employees
Name Null? Type
----------------------- -------- ----------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)

You need to display the last name of all employees which starts with the letter 'A'. Which of the following
queries will yield the required result?

A. SELECT INITCAP (last_name) ||' works as a '||job_id "Job Description" FROM


employees WHERE initcap (last_name) like 'A%';
B. SELECT INITCAP (last_name) ||INITCAP(' works as a: ')|| INITCAP(job_id) "Job
Description" FROM employees WHERE initcap (last_name) like 'A%';
C. SELECT INITCAP (last_name||' works as a '||INITCAP(job_id)) "Job Description"
FROM employees WHERE initcap (last_name) = 'A';
D. SELECT UPPER (LOWER (last_name||' works as a '||job_id)) "Job Description"
FROM employees WHERE lower (last_name) = 'A';

ESTUDO DIRIGIDO – FICHA 01 Página 4 de 21


Oracle 1Z0-051 – Estudo dirigido
14. You need to find the salaries for all the employees who have a higher salary than the Vice President of a
company 'ABC'. Which of the following queries will give you the required result? (Consider the table
structure as given)
SQL> DESC employees
Name Null? Type
----------------------- -------- ----------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)

A. SELECT first_name, last_name, salary FROM employees WHERE salary > (SELECT salary FROM
employees WHERE job_id = 'VICE-PRESIDENT');
B. SELECT first_name, last_name, salary FROM employees WHERE salary = (SELECT salary FROM
Employees WHERE job_id = 'VICE-PRESIDENT');
C. SELECT first_name, last_name, salary FROM employees WHERE job_id = 'VICE-PRESIDENT');
D. None of the above

15. What will be the outcome of the following query? (Consider the given table structure)
SQL> DESC employees
Name Null? Type
----------------------- -------- ----------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)

SELECT first_name, last_name, salary


FROM employees
WHERE salary ANY (SELECT salary FROM employees);

A. It executes successfully giving the desired results


B. It executes successfully but does not give the desired results
C. It throws an ORA error
D. It executes successfully and gives two values for each row obtained in the result set

ESTUDO DIRIGIDO – FICHA 01 Página 5 de 21


Oracle 1Z0-051 – Estudo dirigido
Examine the exhibit and answer the questions 16 to 19 that follow.

16. You need to find out the names of all employees who belong to the same department as the
employee 'Jessica Butcher' who is in department 100 and has an employee ID 40. Which of the
following queries will be correct?
A. SELECT first_name, last_name FROM employees WHERE last_name = 'Butcher' And
first_name = 'Jessica';
B. SELECT first_name, last_name FROM employees WHERE dept_id=100;
C. SELECT first_name, last_name FROM employees WHERE dept_id = (SELECT dept_id
FROM employees WHERE first_name = 'Jessica' AND last_name = 'Butcher');
D. SELECT first_name, last_name FROM employees WHERE department = (SELECT
dept_id FROM employees WHERE first_name = 'Jessica' AND last_name = 'Butcher'
AND dept_id = 100 AND emp_id = 40);

17. You need to find out the employees, which belong to the department of 'Jessica Butcher' and have salary
greater than the salary of 'Jessica Butcher' who has an employee ID of 40. Which of the following queries
will work?

A. SELECT first_name, last_name FROM employees WHERE last_name = 'Butcher' AND


first_name = 'Jessica' AND salary > 10000;
B. SELECT first_name, last_name FROM employees WHERE dept_id = 100;
C. SELECT first_name, last_name FROM employees
WHERE dept_id = (SELECT dept_id
FROM employees
WHERE first_name = 'Jessica'
AND last_name = 'Butcher'
AND emp_id = 40)
AND salary > (SELECT salary
FROM employees
WHERE first_name = 'Jessica'
AND last_name = 'Butcher' AND emp_id = 40);
D. SELECT first_name, last_name FROM employees
WHERE dept_id = (SELECT dept_id FROM employees
WHERE first_name = 'Jessica' AND last_name = 'Butcher'
AND dept_id = 100);

ESTUDO DIRIGIDO – FICHA 01 Página 6 de 21


Oracle 1Z0-051 – Estudo dirigido
18. Based on the answers for questions 16th and 17th, what type of sub-queries is used by them?
A. Single row sub-query
B. Multiple row sub-query
C. Both A and B
D. Inline sub-query

19. Consider two statements about outer and inner queries in context of SQL sub-queries?

i. The inner queries can get data from only one table

ii. The inner queries can get data from more than one table

Which of the above statements are true?

A. (i)
B. (ii)
C. Both (i) and (ii)
D. Neither (i) nor (ii)

Examine the table structure as given. Consider the query given below and answer the questions 20 to 22 that
follow:
SQL> DESC employees
Name Null? Type
----------------------- -------- ----------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)

SELECT first_name, last_name, salary, commission_pct


FROM employees
WHERE salary < ANY (SELECT salary FROM employees WHERE department_id = 100)
AND department_id <> 101;

20. What will be the outcome of the query given above if the < ANY operator is replaced with = ANY
operator?
A. Oracle will treat each value of the salary returned from the sub-query as it does with IN operator
B. There will be no difference in the results
C. The results will differ
D. The execution will thrown an ORA error

ESTUDO DIRIGIDO – FICHA 01 Página 7 de 21


Oracle 1Z0-051 – Estudo dirigido
21. What can be said about the < ANY operator in the query given above?
A. It gives the maximum value of salary
B. It gives the minimum value of salary
C. It means it gives the values that are lesser than the highest
D. None of the above

22. Assume that the < ANY operator is replaced with the > ANY. What is true about this operator?
A. It gives the maximum salary
B. It finds only the maximum salary from the sub-query
C. It gives more than the minimum salary
D. It gives the minimum salary

23. Which of the following can create a view even if the base table(s) does not exist?
A. NOFORCE
B. FORCE
C. OR REPLACE
D. CREATE VIEW

24. Suppose you need to change the start value of this sequence to 1000. Which of the following statements
will help?
A. ALTER dept_deptid_seq INCREMENT BY 100 START WITH 1000 MAXVALUE 9999 NOCACHE
NOCYCLE;
B. The sequence has to be dropped and re-created to start the sequence from 1000.
C. ALTER SEQUENCE dept_deptid_seq START WITH 101
D. ALTER SEQUENCE dept_deptid_seq INCREMENT BY 100 START WITH 101 CYCLE;

25. What is true with respect to accessing the below view? (Assume the table structure given)

SQL> DESC employees


Name Null? Type
----------------------- -------- ----------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)

CREATE VIEW salVU100

ESTUDO DIRIGIDO – FICHA 01 Página 8 de 21


Oracle 1Z0-051 – Estudo dirigido
AS SELECT employee_id ID_NUMBER, last_name NAME, salary*12 ANNUAL_SAL
FROM employees E
WHERE department_id= 100;

A. The view has to be accessed by the original column names defined in the base table
B. The view has to be accessed by the aliases given in the view query
C. View is a simple view
D. None of the above

26. What is true with respect to accessing the below view? (Assume the table structure given)

SQL> DESC employees


Name Null? Type
----------------------- -------- ----------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)

CREATE VIEW salVU100 (ID_NUMBER, NAME, ANNUAL_SAL)


AS SELECT employee_id , last_name, salary*12
FROM employees E
WHERE department_id= 100;

A. It is not mandatory that the number of aliases match the no. of expressions in the sub-query
B. It is mandatory that the no. of aliases listed must match the no. of expressions selected in the sub-query
C. It is mandatory to give aliases while creating a view
D. None of the above
27. The JOB_HISTORY table is owned by a user "Andy". Andy grants the SELECT privilege on the
JOB_HISTORY table to another user "HR". Which statement would create a synonym EMP_JOBS so that
"HR" can execute the following query successfully? (Assume the structure of tables as given)

SQL> desc job_history


Name Null? Type
----------------------- -------- ----------------
EMPLOYEE_ID NOT NULL NUMBER(6)
START_DATE NOT NULL DATE
END_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
DEPARTMENT_ID NUMBER(4)

SELECT * from EMP_JOBS;

A. Andy issues -

ESTUDO DIRIGIDO – FICHA 01 Página 9 de 21


Oracle 1Z0-051 – Estudo dirigido
CREATE SYNONYM EMP_JOBS for JOB_HISTORY

B. HR issues -

CREATE SYNONYM EMP_JOBS for andy.JOB_HISTORY

C. HR issues -

CREATE PUBLIC SYNONYM EMP_JOBS FOR andy.JOB_HISTORY

D. None of the above

28. Which keyword can assure that the DML operations performed on the view stay in the domain of the
view?
A. OR REPLACE
B. CREATE
C. WITH CHECK OPTION
D. None of the above

Consider the following table structure and the given statement and answer the questions 30 and 31
that follow:

SQL> DESC employees


Name Null? Type
----------------------- -------- ----------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)

CREATE OR REPLACE VIEW empvu100


AS
SELECT * FROM employees WHERE department_id = 100 WITH CHECK OPTION CONSTRAINT
empvu100_ck;

ESTUDO DIRIGIDO – FICHA 01 Página 10 de 21


Oracle 1Z0-051 – Estudo dirigido
29. What will the above statement do?
A. It will allow the users to perform INSERT or UPDATE on all departments
B. It will allow the user to perform INSERT or UPDATE any row which has department 100
C. The user can UPDATE any row in the employees table
D. The user can INSERT rows without any restriction in the employees table

30. Suppose you fire an UPDATE statement as shown below:

UPDATE empvu100
Set department_id = 200
Where employee_id = 121;

What will be the outcome of this statement?

A. No rows are updated


B. An ORA error is thrown
C. Both A and B
D. None of the above

31. Consider the following query and answer the following query. Assume that the EMPLOYEE_ID ,
DEPARTMENT_ID and FIRST_NAME columns of EMPLOYEES table are indexed. (Assume the table
structure as given)

SQL> DESC employees


Name Null? Type
----------------------- -------- ----------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)

SELECT first_name, last_name FROM employees WHERE COMMISSION_PCT IS NULL;

Will the existing indexes help in this case if there are 1 million rows in the table EMPLOYEES?

A. Yes
B. No
C. It might help
D. None of the above

ESTUDO DIRIGIDO – FICHA 01 Página 11 de 21


Oracle 1Z0-051 – Estudo dirigido
32. The table EMPLOYEES is updated frequently. When can Indexes be created on this table? (Choose the
most appropriate answer)
A. Indexes should not be created if a table is updated frequently
B. Indexes should be created at the time when the table is created
C. Neither of A nor B
D. None of the above

33. Which of the following privileges will allow you to drop a sequence? (Choose the most appropriate
answer)
A. ALTER SEQUENCE
B. ALTER TABLE
C. DROP SEQUENCE
D. DROP ANY SEQUENCE

34. The following query for the sequence EMP_EMPID_SEQ is executed after a transaction, which inserted
five employee details.

Select emp_empID_seq.CURRVAL from dual;

Suppose the employee transaction rolled back. What will be the result of the above query?

A. The sequence value at the starting of employee transaction


B. NULL
C. The sequence value at the end of employee transaction
D. None of the above

35. What is true about the COALESCE function?


A. It accepts minimum 2 and maximum 5 input parameters
B. It always returns the first NULL value among the input parameters
C. It can accept unlimited number of input parameters
D. It returns the first non-null parameter else it returns a null.

36. What value will the TO_CHAR (number/date, [format], [nlsparameters]) use if the [nlsparameters]
parameter is omitted?
A. It throws an ORA error
B. The [nlsparameters] parameter is mandatory and it can't be omitted.
C. It will use the default parameter values for the session.
D. It will use the default parameter values set during the database design.

ESTUDO DIRIGIDO – FICHA 01 Página 12 de 21


Oracle 1Z0-051 – Estudo dirigido
37. What will the following statement on execution yield?

SELECT TO_CHAR ('01-JAN-13' 'DD-MON-YY') FROM dual;

A. 01-JAN-13
B. 01-01-2013
C. An ORA error
D. 1-JAN-13

38. What will be the outcome of the following query?

SELECT TO_CHAR (TO_DATE('01-JAN-13','DD-MON-YY'), 'fmDdspth "of" Month YYYY


fmHH:MI:SS AM') FROM dual;

A. It will return an ORA error because of the use of double quotes in the Date format
B. 1st January 2013
C. First of JANUARY 2013 12:00:00 AM
D. First of January 2013 12:00:00 AM

39. Assuming the SYSDATE is 01-JAN-13, what will be the outcome of the following query?

SELECT TO_CHAR (SYSDATE, 'DDTH') FROM dual;

A. 1st of January
B. 1st
C. 1 ST
D. 01ST

40. Assuming the SYSDATE is 01-JAN-13, what will be the outcome of the following query?

SELECT TO_CHAR (SYSDATE, 'fmDDTH') FROM dual;

A. 1st of January
B. 1st
C. 1ST
D. 01ST

41. Which of the following functions is used for conditional expressions?


A. TO_CHAR
B. COALESCE
C. NVL
D. CASE

ESTUDO DIRIGIDO – FICHA 01 Página 13 de 21


Oracle 1Z0-051 – Estudo dirigido
42. What will be the outcome of the following query?

SELECT TO_NUMBER('$3,000,000.67','$999,999.99') FROM dual;

A. $3,000,000.67
B. 3000,000.67
C. 3000.67
D. ORA error as the format model has lesser characters than the input string. It should be the same.

43. What is true about the DECODE statement in Oracle DB?

DECODE(expr1,comp1,iftrue1,comp2,[iftrue2])

A. Comp2 is not optional


B. If expr1 is equal to comp1 then comp2 is returned
C. If expr1 is equal to comp1 then iftrue1 is returned
D. None of the above

44. Which of the following SELECT statements lists the highest retail price of all books in the Family
category?
A. SELECT MAX(retail) FROM books WHERE category = 'FAMILY';
B. SELECT MAX(retail) FROM books HAVING category = 'FAMILY';
C. SELECT retail FROM books WHERE category = 'FAMILY' HAVING MAX(retail);
D. None of the above

45. Consider the table structure as given.

SQL> DESC employees


Name Null? Type
----------------------- -------- ----------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)

Examine the error in the below query.

SELECT department_id
FROM employees WHERE hiredate > '01-JAN-1985' AND COUNT(*) > 2
GROUP by department_id
HAVING SUM (salary ) > 1000;

ESTUDO DIRIGIDO – FICHA 01 Página 14 de 21


Oracle 1Z0-051 – Estudo dirigido
A. It executes successfully and generates the required result.
B. It produces an error because COUNT(*) should be specified in the SELECT clause also.
C. It executes successfully but produces no result because COUNT(prod_id) should be used instead of
COUNT(*).
D. It produces an error because COUNT(*) should be only in the HAVING clause and not in the WHERE
clause.

46. Predict the output of the below query

SELECT lower(job),avg(salary )
FROM employees
GROUP BY upper(job);

A. It executes successfully and displays "job" in lower case.


B. It executes successfully but display "job" in original case.
C. It throws error because singe row and aggregate functions cannot be used together.
D. It throws error because case conversion in the SELECT list mismatches with the case conversion GROUP
BY clause.

47. Predict the output of the below query

SELECT department_id , AVG (salary )


FROM employees
GROUP BY department_id
HAVING (department_id >10 and AVG(salary )>2000);

A. It throws error because multiple conditions cannot be given in HAVING clause.


B. It throws error because a non aggregate column cannot be used in HAVING clause.
C. It executes successfully and displays average salary of department higher than 10 and greater than 2000.
D. It executes successfully but no result is displayed.

48. You need to create a table with the following column specifications:
 Employee ID (numeric data type) for each employee. The company will have over 10,000 employees
by 2020;
 Employee Name (character data type) that stores the employee name;
 Hire date, which stores the date of joining the organization for each employee;
 Status (character data type), that contains the cvalue 'ACTIVE' if no data is entered;
 Resume (character large object data type), which contains the resume submitted by the employee.

Which is the correct syntax to create this table?

ESTUDO DIRIGIDO – FICHA 01 Página 15 de 21


Oracle 1Z0-051 – Estudo dirigido

49. You need to extract details of those products in the SALES table where the PROD_ID column contains
the string ‘D_123’. Which WHERE clause could be used in the SELECT command to get the required
output?:
A. WHERE prod_id LIKE ‘%_D123%’ ESPACE ‘_’
B. WHERE prod_id LIKE ‘%D\_123%’ ESPACE ‘\’
C. WHERE prod_id LIKE ‘%_D123%’ ESPACE ‘%_’
D. WHERE prod_id LIKE ‘%D_123%’ ESPACE ‘_’

50. The AT TIME ZONE expression cannot be used to convert which of the following datatypes?
A. DATE
B. TIMSETAMP
C. TIMSETAMP WITH TIME ZONE
D. TIMSETAMP WITH LOCAL TIME ZONE

ESTUDO DIRIGIDO – FICHA 01 Página 16 de 21


Oracle 1Z0-051 – Estudo dirigido
51. Examine the following SQL statement:

52. A function used to convert data into values of the datatype TIMESTAMP WITH LOCAL TIME ZONE is:
A. CAST
B. FROM_TZ
C. TO_TIMESTAMP_TZ
D. SYS_EXTRACT_UTC

53. Examine the following SQL code:


CREATE TABLE REGIONS
( REGION_ID NUMBER(7) UNIQUE,
REGION_NAME VARCHAR2(30),
MANAGER_ID NUMBER(11));

CREATE TABLE OFFICES


( OFFICE_ID NUMBER(11) PRIMARY KEY,
REGION_ID NUMBER(11, 2),
CONSTRAINT OFRE FOREIGN KEY (REGION_ID) REFERENCES REGIONS (REGION_ID));

What will be result of the preceding SQL statements?


A. They will create two tables, each consisting of three columns.
B. The REGIONS table will be create successfully, but the OFFICES table will not, due to a syntax error;
C. The REGIONS table and OFFICES table will be create successfully, but no foreign key constraint will
result.
D. The constraint OFRE will be created successfully.

ESTUDO DIRIGIDO – FICHA 01 Página 17 de 21


Oracle 1Z0-051 – Estudo dirigido

54. Review the following SQL Statement:


CREATE TABLE INSTRUCTORS
( INSTRUCTOR_ID NUMBER,
EXEMPT VARCHAR2(5),
VACATION NUMBER,
PAY_RATE NUMBER);

INSERT INTO INSTRUCTORS VALUES (1, 'YES', NULL, 25);


INSERT INTO INSTRUCTORS VALUES (2, NULL, NULL, NULL);

UPDATE INSTRUCTORS SET EXEMPT = 'YES', VACATION = 15 WHERE PAY_RATE > 20;
A. No records will be updated;
B. One record will be updated;
C. Two records will be updated;
D. At least one of the statements will not execute.

55. Review the following SQL statements:


01 CREATE TABLE CLASSES
02 (CLASS_ID NUMBER(13) PRIMARY KEY,
03 INSTRUCTOR_ID NUMBER(13)
04 );
05 INSERT INTO CLASSES VALUES (1, 1);
06 INSERT INTO CLASSES VALUES (2, 2);

Which of the following DELETE statements will delete the second of theses two rows? (Choose two).

A. DELETE FROM TABLE CLASSES WHERE CLASS_ID =2;


B. DELETE FROM CLASSES WHERE CLASS_ID =2;
C. DELETE CLASSES WHERE CLASS_ID =2;
D. DELETE TABLE CLASSES WHERE CLASS_ID =2;

56. Examine the following SQL code:


CREATE TABLE STUDENTS
( STUDENT_ID NUMBER(13) PRIMARY KEY,
F_NAME VARCHAR2(25),
L_NAME VARCHAR2(35),
SSN VARCHAR2(11),
STATUS VARCHAR2(10),
REG_DATE TIMESTAMP);

CREATE SEQUENCE STUDENT_ID_SEQUENCE;


Which of the following are valid INSERT statements for this table? (Choose two.):

ESTUDO DIRIGIDO – FICHA 01 Página 18 de 21


Oracle 1Z0-051 – Estudo dirigido
A. INSERT INTO STUDENTS (STUDENT_ID, F_NAME, L_NAME, STATUS) VALUES
(STUDENT_ID_SEQUENCE.NEXTVAL, (SELECT 'JOHN', 'SMITH' FROM DUAL), 'ACTIVE');
B. INSERT INTO STUDENTS VALUES (STUDENT_ID_SEQUENCE.NEXTVAL, (SELECT 'JOHN'
FROM DUAL), 'SMITH', NULL, 'ACTIVE', SYSDATE);
C. INSERT INTO STUDENTS (STUDENT_ID, F_NAME, L_NAME, STATUS) AS SELECT
STUDENT_ID_SEQUENCE.NEXTVAL, 'JOHN', 'SMITH', 'ACTIVE', NULL FROM DUAL;
D. INSERT INTO STUDENTS (STUDENT_ID, F_NAME, L_NAME, REG_DATE) SELECT
STUDENT_ID_SEQUENCE.NEXTVAL, 'JOHN', 'SMITH', SYSTIMESTAMP FROM DUAL;

57. Examine the illustration. You are tasked to produce a report that shows the number of students at each
campus, in each status Which of the following queries successfully performs the task ?

A. SELECT CAMPUS, STATUS FROM STUDENTS GROUP BY CAMPUS, STATUS,


COUNT(STUDENT_ID);
B. SELECT CAMPUS, STATUS, COUNT(STUDENT_ID) FROM STUDENTS GROUP BY
COUNT(STUDENT_ID);
C. SELECT CAMPUS, DISTINCT STATUS, COUNT(STUDENT_ID) FROM STUDENTS GROUP BY
CAMPUS;
D. SELECT CAMPUS, STATUS, COUNT(STUDENT_ID) FROM STUDENTS GROUP BY CAMPUS,
STATUS;
58. Examine the following SQL code:

CREATE TABLE INSTRUCTORS


( ID NUMBER(13) PRIMARY KEY,
LAST_NAME VARCHAR2(25),
VACATION NUMBER,
PAY_RATE NUMBER,
DEPARTMENT_ID NUMBER);

ESTUDO DIRIGIDO – FICHA 01 Página 19 de 21


Oracle 1Z0-051 – Estudo dirigido
INSERT INTO INSTRUCTORS VALUES (1, 'Smith', 17, 55, 7);
INSERT INTO INSTRUCTORS VALUES (2, 'Jones', 12, 27, 3);
INSERT INTO INSTRUCTORS VALUES (3, 'Cohen', 47, 75, 1);
INSERT INTO INSTRUCTORS VALUES (4, 'Green', 14, 80, 6);
INSERT INTO INSTRUCTORS VALUES (5, 'Riley', 21, 54, null);
INSERT INTO INSTRUCTORS VALUES (6, 'Simpson', 8, 12, 7);
INSERT INTO INSTRUCTORS VALUES (7, 'Bryant', 99, 90, null);

SELECT DEPARTMENT_ID, LAST_NAME FROM INSTRUCTORS WHERE VACATION < 14 AND


PAY_RATE < 60 AND DEPARTMENT_ID NOT IN (1, 2 ,7);
A. It will return one row;
B. It will return two rows;
C. It will return three rows;
D. It will return four rows;

59. Examine the data of ORD_ITEMS table:

ORD_NO ITEM_NO QTY


1 111 10
1 222 20
1 333 30
2 333 30
2 444 40
3 111 40

Evaluate the following query:


SQL> SELECT item_no, AVG (qty)
FROM ORD_ITEMS
HAVING AVG (qty)> MIN (qty) * 2
GROUP BY item_no;

Which alternative is true as regards the output of query above?


A. Shows an error because the HAVING clause must be specified after the GROUP BY clause.
B. It exhibits an error because all aggregate functions used in the HAVING clause must be specified in the
SELECT list.
C. It exhibits the item numbers with their average amount, where the average number is more than double the
minimum amount of that item in the table.
D. It exhibits the item numbers with their average amount, where the average number is more than double the
minimum total amount of all items in the table.

ESTUDO DIRIGIDO – FICHA 01 Página 20 de 21


Oracle 1Z0-051 – Estudo dirigido

60.

ESTUDO DIRIGIDO – FICHA 01 Página 21 de 21

You might also like