SQL Certificate Mock Exams
SQL Certificate Mock Exams
A. 140
B. 144
C. 150
D. 100
A. SELECT
B. GROUP BY
C. INTERSECT
D. INSERT
4. Write a query to display employee details Name, Department, SalaryandJob from EMP table.
A. Simple views
B. Complex views
C. Both A and B
D. None of the above
A. The SELECT clause should have the same number of columns, data types can be different
B. The SET operators can be used only for combining two queries
C. The data type of each column in the 2nd query must match the data type of its
corresponding column in the first query.
D. None of the above
9. Which among the following is a common technique for inserting rows into a table?
Choosethemostsensibleandappropriateanswer
11. Predict the output when below statement is executed in SQL* Plus?
DESC emp
A. Raises error "SP2-0042: unknown command "desc emp" - rest of line ignored."
B. Lists the columns of EMP table
C. Lists the EMP table columns, their data type and nullity
D. Lists the columns of EMP table along with their data types
A. 100
B. 999
C. NULL
D. 1099
13. With respect to the given query, if the JOIN used is replaced with NATURAL JOIN, it
throws an error. What is the reason for this error?
A. When the NATURAL JOIN is used, a WHERE clause is mandatory, omitting which gives an error
B. The ON clause should be replaced with the USING clause
C. The words NATURAL, JOIN and USING are mutually exclusively in the context of the same join
clause
D. A query can't combine the NATURAL JOIN and ON orUSING clauses while joining.
14.Which of the following syntax models is used in extensively in the software systems
worldwide?
A. The tables used in the main query are also used in a co-related sub-query
B. The sub-queries which reference a column used in the main query are called co-related sub-
queries
C. The sub-queries which are written without parenthesis are called co-related sub-queries
D. The sub-queries which mandatorily use different tables than those used in the main query
are called co-related sub-queries
UPDATE employees
SET employee_id = NULL;
WHERE job_id = 'CLERK';
A. The first column of the data set will get updated to NULL
B. The 3rd column of the first row will get updated to NULL
C. The 3rd column of all the rows will get updated to NULL
D. And ORA error will be thrown
A. 500001
B. 51
C. 501
D. 5001
20. You create a table and name it as COUNT. What will be the outcome of CREATE
TABLE script?
SELECT *
FROM employees
WHERE salary BETWEEN (SELECT max(salary)
FROM employees
WHERE department_id = 100)
AND (SELECT min(salary) FROM employees where department_id = 100);
This query returns an error. What is the reason for the error?
23.What is true with respect to INNER JOINS and OUTER JOINS in Oracle DB?
24. Which of the following can create a view even if the base tables does not exist?
A. NOFORCE
B. FORCE
C. OR REPLACE
D. CREATE VIEW
25. Which of the following ANSI SQL: 1999 join syntax joins are supported by Oracle?
A. Cartesian products
B. Natural joins
C. Full OUTER join
D. Equijoins
26. What among the following are the pre-requisites for creating a table?
28.You need to display all the non-matching rows from the EMPLOYEES table and the
non-matching rows from the DEPARTMENT table without giving a Cartesian product of
rows between them. Which of the following queries will give the desired output?
A. SELECT *
FROM employees e, department d
WHERE e.department_id = d.department_id ;
B. SELECT *
FROM employees e NATURAL JOIN department d;
C. SELECT *
FROM employees e FULL OUTER JOIN department d
ON e.department_id = d.department_id ;
D. SELECT *
FROM employees e JOIN department d
ON ( e.department_id > d.department_id ) ;
29. Which of the below alphanumeric characters are used to signify concatenation
operator in SQL?
A. +
B. ||
C. -
D. ::
30.What is the best way to change the precedence of SET operators given the fact that
they have equal precedence?
A. The order of usage of the SET operators can be changed to change the precedence
B. The equal precedence cannot be changed
C. Parenthesis can be used to change the precedence
D. None of the above
31.What will be displayed in the result of this query?
A. It will display distinct department ids contained jointly in EMPLOYEES and DEPARTMENTS
table
B. It will throw ORA error
C. No rows selected
D. None of the above
32. Which of the following commands ensures that no DML operations can be
performed on a view?
A. NOFORCE
B. FORCE
C. WITH READ ONLY
D. OR REPLACE
33. What is true about the NOFORCE option in CREATE VIEW statement?
A. Object privileges are lost when a view is created using this keyword
B. There is no need of re granting the object privileges previously granted on it
C. Neither of A nor B
D. None of the above
A. Multiple-row functions
B. Single column functions
C. Single value functions
D. Multiple columns functions
A. VARCHAR2
B. Character
C. LONG
D. NULLIF
39. 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.
A. 12
B. 6
C. 9
D. Throws exception because COUNT function doesn't works with NULL values
40. Pick the element which you must specify while creating a table.
A. Column name
B. Column Data type
C. Column size
D. All of the above
42. 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.
A. 12
B. 6
C. 9
D. Throws exception because COUNT function doesn't works with NULL values
43. You need to find the results obtained by the above query only for the departments
100 and 101. Which of the following clauses should be added / modified to the above
query?
A. GROUP BY
B. GROUPING SETS
C. CUBE
D. ROLLUP
46. What among the following is true about the DELETE statement?
47. 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?
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.
48.What among the following happens when we issue a DELETE statement on a table?
Choosethemostappropriateanswer
A. A prompt pops up asking the user whether he/she is sure of deleting the rows requested
B. The rows obeying the condition given in the DELETE statement are removed immediately
C. The requested rows are removed immediately without any prompt.
D. None of the above
50.What will happen if a value is provided to the &N variable in the above query
optionCinquestion76 does not match with any row? Choosethebestanswer
51.What is the default sorting order of the results when UNION ALL operator is used?
A. Descending
B. Ascending
C. Either A or B
D. All of the above
52. 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.
A. 12
B. 6
C. 9
D. Throws exception because COUNT function doesn't works with NULL values
A. 255
B. 100
C. 2
D. 16
54. 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.
A. 12
B. 6
C. 9
D. Throws exception because COUNT function doesn't works with NULL values
i. The function accepts multiple numeric inputs and returns variance of all the values
ii. The function accepts a number column and returns variance of all column values including
NULLs
iii. The function accepts a number column and returns variance of all column values excluding
NULLs
A. i and iii
B. i and ii
C. ii
D. iii
56. Which clause is used to filter the query output based on aggregated results using a
group by function?
A. WHERE
B. LIMIT
C. GROUP WHERE
D. HAVING
57. A user named "Kevin" wants to access a table which is owned by another user
named "Jonathan". Which of the following will work for Kevin?
58.What is true about the ALL operator used for sub-queries? Choosethemostappropriateanswer.
59. Suppose you select DISTINCT departments and employee salaries in the view query
used in above question. What will be the outcome if you try to remove rows from the
view dept_sum_vu?
60.What will happen if the SELECT list of the compound queries returns both a
VARCHAR2 and a NUMBER data type result?
A. Oracle will convert them implicitly and return a VARCHAR2 data type result
B. Oracle will convert them implicitly and return a NUMBER data type result
C. An ORA error is thrown
D. None of the above
A. A schema is owned by a database user and has the same name as that user
B. Each user owns a single schema
C. Schema objects include database links
D. All of the above
62. In which order the values will get inserted with respect to the above INSERT
statement?
65. Which of the below SQL query will display employee names, department, and annual
salary?
D. Annual salary cannot be queried since the column doesn't exists in the table
67. Which of the following SELECT statements lists the highest retail price of all books
in the Family category?
68. Which of the following functions can be used to include NULL values in calculations?
A. SUM
B. NVL
C. MAX
D. MIN
69.Which statements best describes the inference drawn from the questions 34 and 35?
A. 2
B. 3
C. 1
D. hi
Answer:
Answer1: A. The ROUND function will round off the value 144.23 according to the specified
precision -1 and returns 140.
Examine the structure of the EMPLOYEES table as given and answer the questions 2 and
3 that follow.
Answer2: A. Using parenthesis will explicitly change the order of evaluation when INTERSECT is
used with other operators.
Answer4: A.Select the required from the tables each separated by a comma.
Answer5: C. Simple and Complex views are two types of views. Simple views are based on a
subquery that references only one table and doesn't include group functions, expressions, or
GROUP BY clauses. Complex views are based on a subquery that retrieves or derives data from
one or more tables and can contain functions or grouped data.
Answer6: C. All the combined should have the same no. of columns when using SET operators.
The corresponding columns in the queries that make up a compound query must be of the same
data type group.
Answer:7 D. Multiple-row subqueries return more than one row of results.Operators that can be
used with multiple-row subqueries include IN, ALL, ANY, and EXISTS.
Answer8: C. An index can be created to speed up the query process. DML operations are always
slower when indexes exist. Oracle 11g creates an index for PRIMARY KEY and UNIQUE constraints
automatically. An explicit index is created with the CREATE INDEX command. An index can be used
by Oracle 11g automatically if a query criterion or sort operation is based on a column or an
expression used to create the index.
Answer9: A. Using the SELECT clause is the most common technique for inserting rows into
tables. It reduces the effort of manually keying in values for each column.
Answer11: C. DESCRIBE is used to show the table structure along with table columns, their data
type and nullity
Answer13: C, D.
Answer14: C. The ANSI SQL: 1999 syntax though not used as much as the traditional Oracle
syntax, it still is one of the syntaxes that may be used in Oracle SQL
Answer15: B. Correlated subquery references a column in the outer query and executes the
subquery once for every row in the outer query while Uncorrelated subquery executes the
subquery first and passes the value to the outer query.
Answer16: D. The constraints on the column must be obeyed while updating its value. In the given
UPDATE statement, error will be thrown because the EMPLOYEE_ID column is a primary key in the
EMPLOYEES table which means it cannot be NULL.
Answer17: D. The WHERE clause can be omitted and the relevant conditions can be
accommodated in the JOIN..ON clause itself as shown in the given query
Answer18: A. Table1 JOIN table2 JOIN table3 is not allowed without the ON clauses for between
each JOIN
Answer19: C. The leading zeroes in the right operand of expression are ignored by Oracle.
Answer20: A, C. You cannot create a table with the name same as an Oracle Server reserved
word.
Answer21: C. The BETWEEN operator can be used within a sub-query but not with a sub-query.
Answer22: D. Functions can perform calculations, perform case conversions and type
conversions.
Answer23: A, C. A join can be an inner join,in which the only records returned have a matching
record in all tables,or an outer join, in which records can be returned regardless of whether there's
a matching record in the join.An outer join is created when records need to be included in the
results without having corresponding records in the join tables. These records are matched with
NULL records so that they're included in the output.
Answer24: B. Ff you include the FORCE keyword in the CREATE clause, Oracle 11g creates the
view in spite of the absence of any referenced tables. NOFORCE is the default mode for the
CREATE VIEW command, which means all tables and columns must be valid, or the view isn't
created.
Answer25: D.
Answer26: A, B. A user must possess the CREATE TABLE privilege and must have sufficient space
to allocate the initial extent to the table segment.
Answer27: A.
Answer28: C. The FULL OUTER JOIN returns the non-matched rows from both the tables. A full
outer join includes all records from both tables, even if no corresponding record in the other table
is found.
Answer30: C. Parenthesis can be used to group the specific queries in order to change the
precedence explicitly. Parentheses are preferred over other SET operators during execution.
Answer31: A. UNION Returns the combined rows from two queries, sorting them and removing
duplicates.
Answer32: C. The WITH READ ONLY option prevents performing any DML operations on the view.
This option is used often when it's important that users can only query data, not make any changes
to it.
Answer33: B, C. NOFORCE is the default mode for the CREATE VIEW command, which means all
tables and columns must be valid, or the view isn't created.
Answer34: B. The OR REPLACE option notifies Oracle 11g that a view with the same name might
already exist; if it does, the view's previous version should be replaced with the one defined in the
new command.
Answer35: A. There are basically two types of functions - Single row and Multiple row functions.
Answer36: B. Character, Date, Conversion, General, Number are the types of Single row functions.
Answer37: B. Multiple Row functions always work on a group of rows and return one value per
group of rows.
Answer38: C. Group functions are same as Multi row functions and aggregate functions.
Answer39: A. The COUNT ∗ counts the number of rows including duplicates and NULLs. Use
DISTINCT and ALL keyword to restrict duplicate and NULL values.
Answer40: D. A table must have atleasr one column, its data type specification, and precision
ifrequired.
Answer41: C. Specifying alias name is good practice to improve the readability of the code and
the view queries.
Answer42: C. COUNT column ignores the NULL values but counts the duplicates.
Answer43: C. The NATURAL JOIN clause implicitly matches all the identical named columns. To
add additional conditions the WHERE clause can be used.
Answer45: B. The sequence of the column alias not matters much as they don't carry any
behavioral attribute.
Answer46: B. The WHERE clause predicate is optional in DELETE statement. If the WHERE clause
is omitted, all the rows of the table will be deleted.
Answer47: B. Provided the last names in the employees table are in a proper case, the condition
WHERE last_name = 'smith' will not be satistified and hence no results will be displayed.
Answer48: C. As a part of the active or a new transaction, the rows in the table will be deleted.
Answer49: D. A compound query is one query made up of several queries using different tables.
Answer50: D.
Answer51: B. A compound query will by default return rows sorted across all the columns,from
left to right in ascending order.The only exception is UNION ALL, where the rows will not be sorted.
The only place where an ORDER BY clause is permitted is at the end of the compound query.
Answer52: C. COUNTALLcolumn ignores the NULL values but counts the duplicates.
Answer53: A.
Answer55: C. The VARIANCE function accepts single numeric argument as the column name and
returns variance of all the column values considering NULLs.
Answer56: D. HAVING Clause is used for restricting group results. You use the HAVING clause to
specify the groups that are to be displayed, thus further restricting the groups on the basis of
aggregate information. The HAVING clause can precede the GROUP BY clause, but it is
recommended that you place the GROUP BY clause first because it is more logical. Groups are
formed and group functions are calculated before the HAVING clause is applied to the groups in
the SELECT list.
Answer57: B.
Answer58: C. '> ALL' More than the highest value returned by the subquery. '< ALL' Less than the
lowest value returned by the subquery. '< ANY' Less than the highest value returned by the
subquery. '> ANY' More than the lowest value returned by the subquery. '= ANY' Equal to any
value returned by the subquery sameasIN. '[NOT] EXISTS' Row must match a value in the subquery.
Answer59: C. The view DEPT_SUM_VU is still a complex view as it uses DISTINCT keyword. Hence,
DML operations are not possible on it.
Answer60: C. Oracle does not convert data types implicitly.
Answer61: D. The user space in a database is known as schema. A schema contains the objects
which are owned or accessed by the user. Each user can have single schema of its own.
Answer62: B. If the columns are mentioned in the INSERT clause, the VALUES keyword should
contain values in the same order
Answer63: B. A default value can be specified for a column during the definition using the
keyword DEFAULT.
Answer66: A. The SUBSTRstring, x, y function accepts three parameters and returns a string
consisting of the number of characters extracted from the source string, beginning at the specified
start position x. When position is positive, then the function counts from the beginning of string to
find the first character. When position is negative, then the function counts backward from the end
of string.
Answer67: A. Since the category FAMILY has to be restricted before grouping, table rows must be
filtered using WHERE clause and not HAVING clause.
Answer68: B. NVL is a general function to provide alternate values to the NULL values. It can
really make a difference in arithmetic calculations using AVG, STDDEV and VARIANCE group
functions.
Answer69: C. As the combination of the job codes and departments is unique, there are no
duplicates obtained.
Answer70: A. the LENGTH function simply gives the length of the string.
Processing math: 100%