wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

FCPC-DBMS2-Prelim Exam

Total questions: 50

Worksheet time: 50mins

Name
Class
Date
1.

What will be the outcome of the following query?

SELECT ROUND(144.23,-1) FROM dual;
a)

140

b)

144

c)

150

d)

100

2.

You are currently located in New Jersey and have connected to a remote database in San Diego. You issue the following command.

SELECT ROUND (sysdate-hire_date,0) FROM employees WHERE (sysdate-hire_date)/180 = 2;


What is the outcome of this query?

a)

An error because the ROUND function cannot be used with Date arguments.

b)

An error because the WHERE condition expression is invalid.

c)

Number of days since the employee was hired based on the current San Diego date and time.

d)

Number of days since the employee was hired based on the current New Jersey date and time.

3.

You need to display the names of the employees who have the letter 's' in their first name and the letter 't' at the second position in their last name. Which query would give the required output?

a)
SELECT first_name, last_name FROM employees WHERE INSTR(first_name,'s') <> 0 AND SUBSTR(last_name,2,1) = 't';
b)
SELECT first_name, last_name FROM employees WHERE INSTR(first_name,'s') <> '' AND SUBSTR(last_name,2,1) = 't';
c)
SELECT first_name, last_name FROM employees WHERE INSTR(first_name,'e') IS NOT NULL AND SUBSTR(last_name,2,1) = 't';
d)
SELECT first_name, last_name FROM employees WHERE INSTR(first_name,'e') <> 0 AND SUBSTR(last_name,LENGTH(first_name),1) =  
't';
4.

Which of the following statements is true regarding the COUNT function? (Select all that apply)

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.

Examine the structure of the EMPLOYEES table as given. 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.

6.

What will be the outcome of the following query? (Consider the structure of the EMPLOYEES table as given)

SELECT employee_id , NVL(salary, 0) FROM employees WHERE first_name like 'P%' ORDER BY first_name;
a)

It will display 0 in the salary column for all the employees whose first name starts with a 'P'

b)

It will display the salaries for the employees whose name start with a 'P' and 0 if the salaries are NU

c)

It will throw an ORA error as the ORDER BY clause should also contain the salary column.

d)

The NVL function should be correctly used as NVL (0, salary)

7.

What will be the outcome of the following query? (Consider the structure of the EMPLOYEES table as given)

SELECT NVL2(job_id,'Regular Employee','New Joinee') FROM employees;
a)

It will return the value 'Regular Employee' for all the employees who have NULL job IDs

b)

It will return the value 'New Joinee' for all the employees who have NULL job IDs

c)

It will return 'Regular Employee' if the job ID is NULL

d)

It will throw an ORA error on execution.

8.

Examine the structure of the EMPLOYEES table as given.

What will be the outcome of the query mentioned below?


SeLECT first_name, salary, NVL2(commission_pct,  salary + (salary * commission_pct), salary) "Income" 
FROM employees 
WHERE first_name like 'P%'  
ORDER BY first_name;
a)

Salary will be returned if the Commission for the employee is NOT NULL.

b)

Commission_pct will be returned if the Commission for the employee is NOT NULL.

c)

Employees with the first name starting with 'P' and salary+(salary*commission_pct) will be returned if the employee earns a commission.

d)

The query throws an error because a mathematical expression is written inside NVL2.

9.

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 forABEL is a sa_rep

c)

The job id for abel is SA_REP

d)

The job id for abel is sa_rep

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;

(Select all that apply)

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;

11.

Examine the structure of the EMPLOYEES table as given. What will be the outcome of the following query?


SELECT upper(&jobid) FROM employees;

a)

It results in an error as substitution variables cannot be used with single row functions

b)

It prompts the user to input the jobid on each execution and then displays the job id in UPPER case

c)

It gives the jobid as it is present in the table EMPLOYEES without making any change

d)

It will not ask the user to input the job id and will convert all the job IDs in the table in UPPER case

12.

Examine the structure of the EMPLOYEES table as given here. You need to generate a report which shows the first name, last name and the salary for all the employees in the department 100. The report should show the results in the form 'Andy Smith earns 50000'. Which of the following queries will give the required output? (Select all that apply)

a)

SELECT concat (first_name,concat (' ', concat(last_name, concat(' earns ', SALARY)))) Concat_String FROM employees WHERE department_id =

100;

b)

SELECT concat (first_name, last_name||' '|| salary) FROM employees WHERE department_id = 100;

c)

SELECT concat (first_name, concat(last_name, ' '))||earns||salary FROM employees WHERE department_id = 100;

d)

SELECT concat (first_name, concat(last_name, 'earns salary') FROM employees WHERE department_id = 100;

13.

You need to extract a consistent 15 character string based on the SALARY column in the EMPLOYEES table. If the SALARY value is less than 15 characters long, zeros must be added to the left of the value to yield a 15 character string. Which query will fulfill this requirement?

a)
SELECT rpad(salary, 15,0) FROM employees;
b)
SELECT lpad(salary,15,0) FROM employees;
c)
SELECT ltrim(salary,15,0) FROM employees;
d)
SELECT trim(salary,15,0) FROM employees;
14.

You need to display the last 2 characters from the FIRST_NAME column in the EMPLOYEES table without using the LENGTH function. Which of the following queries can fulfill this requirement? (Select all that apply)

a)

SELECT SUBSTR(first_name, 2) FROM employees;

b)

SELECT SUBSTR(first_name, -2) FROM employees;

c)

SELECT RTRIM(first_name, 2) FROM employees;

d)

SELECT TRIM(first_name, 2) FROM employees;

15.

Examine the structure of the EMPLOYEES table as given here. You need to retrieve the first name, last name (separated by a space) and the formal names of employees where the combined length of the first name and last name exceeds 15 characters. A formal name is formed by the first letter of the First Name and the first 14 characters of the last name. Which of the following queries will fulfill this requirement? (Select all that apply)

a)

SELECT first_name, last_name ,SUBSTR(first_name, 1,1)||' '||SUBSTR(last_name, 1,14) formal_name FROM employees;

b)

SELECT first_name, last_name ,SUBSTR(first_name, 1,14)||' '||SUBSTR(last_name, 1,1) formal_name FROM employees WHERE length

(first_name) + length(last_name) < 15;

c)

SELECT first_name, last_name ,SUBSTR(first_name, 1,1)||' '||SUBSTR(last_name, 1,14) formal_name FROM employees WHERE length

(first_name) + length(last_name) =15;

d)

SELECT first_name, last_name ,SUBSTR(first_name, 1,1)||' '||SUBSTR(last_name, 1,14) formal_name FROM employees WHERE length

(first_name) + length(last_name) > 15;

16.

Examine the structure of the EMPLOYEES table as given below. You need to allocate the first 12 employees to one of the four teams in a round-robin manner. The employee IDs start with a 100. Which of the following queries will fulfill the requirement? (Select all that apply)

a)

SELECT * FROM employees WHERE employee_id between 100 and 111 ORDER BY employee_id;

b)

SELECT first_name, last_name, employee_id, mod(employee_id, 4) Team# FROM employees WHERE employee_id between 100 and 111

ORDER BY employee_id;

c)

SELECT first_name, last_name,mod(employee_id, 2) Team# FROM employees WHERE employee_ID <> 100;

d)

SELECT first_name, last_name, mod(employee_id, 4) Team# FROM employees WHERE employee_ID = 100;

17.

Which of the following commands is used to count the number of rows and non-NULL values in Oracle database? (Select all that apply)

a)

NOT NULL

b)

INSTR

c)

SUBSTR

d)

COUNT

18.
What will be the outcome of the query given below? SELECT 100+NULL+999 FROM dual;
a)
100
b)
999
c)
NULL
d)
1099
19.

Which of the following statements are true regarding the single row functions? (Select all that apply)

a)

They accept only a single argument.

b)

They can be nested only to two levels.

c)

Arguments can only be column values or constants.

d)

They can return a data type value different from the one that is referenced.

20.
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****
21.

Out of the below clauses, where can the single-row functions be used?

a)

SELECT

b)

WHERE

c)

ORDER BY

d)

All of the above

22.

Which of the following is not a property of functions? (Select all that apply)

a)

Perform calculations on data

b)

Convert column data types

c)

Modify individual data items

d)

None of the above

23.
What is the most appropriate about single row functions?
a)
They return no value
b)
They return one result per row and operate on all the rows of a table.
c)
They return one result per row with input arguments
d)
They return one result per set of rows and operate on multiple rows.
24.
What among the following is a type of single-row function? (Select all that apply)
a)
VARCHAR2
b)
Character
c)
LONG
d)
NULLIF
25.
What is the most appropriate about Multiple Row Functions?
a)
They return multiple values per each row. 
b)
They return one result per group of rows and can manipulate groups of rows. 
c)
They return one result per row and can manipulate groups of rows. 
d)
They return multiple values per a group of row.
26.
Which of the following are also called Group functions?
a)
Single row functions
b)
Multi group functions
c)
Multiple row functions
d)
Single group functions.
27.
Which of the following is true about Single Row Functions?
a)
They can be nested
b)
They accept arguments and return more than one value.
c)
They cannot modify a data type
d)
They cannot accept expressions as arguments.
28.
What is the number of arguments Single Row functions accept?
a)
0
b)
Only 1
c)
Only 2
d)
1 or more than 1
29.
Which of the following can be an argument for a Single Row Function?
a)
Data types
b)
SELECT statements
c)
Expression
d)
Table name
30.
What is true about Number functions?
a)
They return both Character as well as Number values
b)
They can't accept expressions as input
c)
Number functions can't be nested.
d)
They accept Number arguments and return Number values only.
31.
What will be the outcome of the following query? SELECT lower('HI WORLD !!!') FROM dual;
a)
Hi World !!!
b)
Hi WORLD !!!
c)
hi world !!!
d)
HI WORLD !!!
32.
What will be the outcome of the following query? SELECT lower(upper(initcap('Hello World') )) FROM dual;
a)
Hello World
b)
HELLO world
c)
hello World
d)
hello world
33.
What will be the outcome of the following query? SELECT length('hi') FROM dual;
a)
2
b)
3
c)
1
d)
hi
34.
What is the difference between LENGTH and INSTR functions in Oracle DB?
a)
They give the same results when operated on a string.
b)
LENGTH gives the position of a particular character in a string
c)
INSTR gives the position of a particular character in a string while LENGTH gives the length of the string.
d)
LENGTH and INSTR can be used interchangeably.
35.
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;
36.
What is true regarding the TRIM function?
a)
It is similar to SUBSTR function in Oracle
b)
It removes characters from the beginning or end of character literals, columns or expression
c)
TRIM function cannot be applied on expressions and NUMBERS
d)
TRIM function can remove characters only from both the sides of a string.
37.
You need to remove the occurrences of the character '.' and the double quotes '"' from the following titles of a book present in the table MAGAZINE. "HUNTING THOREAU IN NEW HAMPSHIRE" THE ETHNIC NEIGHBORHOOD." Which of the following queries will give the required result?
a)
SELECT LTRIM(Title,'"') FROM MAGAZINE;
b)
SELECT LTRIM(RTRIM(Title,'."'),'"') FROM MAGAZINE;
c)
SELECT LTRIM (Title,'"THE') FROM MAGAZINE;
d)
SELECT LTRIM(RTRIM(Title,'."THE'),'"') FROM MAGAZINE;
38.
What is the maximum number of parameters the ROUND function can take?
a)
0
b)
1
c)
2
d)
3
39.

The SQL statement to count distinct rows from a column is,

a)

select COUNT DISTINCT columnname AS total_rows from tablename;

b)

select (COUNT DISTINCT columnname) AS total_rows from tablename;

c)

select DISTINCT columnname AS total_rows from tablename;

d)

select COUNT (DISTINCT) AS total_rows from tablename;

40.

The COUNT() function also counts the NULL values.

a)

True

b)

False

41.

The SUM() function returns - - -

a)

some random values from the given column

b)

the total number of columns in the database

c)

the total number of tables in the given databases

d)

the total sum of a given numeric column

42.

The average value of the given numeric column is calculated by using - - - function.

a)

GETAVG()

b)

FINDAVG()

c)

AVG()

d)

AVGVALUE()

43.

Which one of the following is an Multiple row Functions?

a)

COUNT()

b)

LEN()

c)

AVERAGE()

d)

NOW()

44.

A table T_COUNT has 12 number values as 1, 2, 3, 32, 1, 1, null, 24, 12, null, 32, null. Predict the output of the below query.

SELECT COUNT (*) FROM t_count;
a)

12

b)

6

c)

9

d)

Throws exception because COUNT function doesn't works with NULL values

45.

1. To perform condition based on a list, we need to use ____________ clause

a)

between

b)

select

c)

in

46.

1. All aggregate functions ignore the __________________ value.

a)

similar

b)

NULL

c)

column

47.

1. The OR operator displays a record if ANY of the conditions listed are true. The AND operator displays a record if ALL of the conditions listed are true

a)

True

b)

False

48.

Which of the following are single row functions:

a)

SUBSTR( )

b)

SUM( )

c)

TRIM( )

d)

ROUND( )

49.

1. The HAVING clause places conditions on _____________

a)

Columns

b)

Tables

c)

Group

50.
What is the purpose of  *?
a)
Selects ALL fields from the table
b)
Selects only the first field in the table
c)
Selects the last field in the table
d)
Shows only the first row in the table