Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2K views

SQL Test With Answers

This document contains 20 multiple choice questions testing knowledge of SQL and Oracle Database 11g. The questions cover topics such as SQL statements, functions, joins, subqueries, views, constraints, privileges and roles. Sample SQL queries are provided with each question to evaluate syntax, execution and output.

Uploaded by

hoanganhson
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

SQL Test With Answers

This document contains 20 multiple choice questions testing knowledge of SQL and Oracle Database 11g. The questions cover topics such as SQL statements, functions, joins, subqueries, views, constraints, privileges and roles. Sample SQL queries are provided with each question to evaluate syntax, execution and output.

Uploaded by

hoanganhson
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

ORACLE DATABASE 11G - INTRODUCTION TO SQL

EXAM TESTING

QUESTION 1

Identify the SELECT statements that execute successfully.

A. SELECT first_name, last_name, job_id, salary*12 AS Yearly Sal


FROM employees;

B. SELECT first_name, last_name, job_id, salary*12 "yearly sal"


FROM employees;

C. SELECT first_name, last_name, job_id, salary AS "yearly sal"


FROM employees;

D. SELECT first_name+last_name AS name, job_Id, salary*12 yearly sal


FROM employees;

Answers: A, B

QUESTION 2

The TO_NUMBER function converts either character strings or date values to a number in the format
specified by the optional format model.

A. True
B. False

Answers: B

QUESTION 3

Evaluate the following query:


SQL> SELECT promo_name || q'{'s start date was }' || promo_begin_date AS "Promotion Launches"
FROM promotions;

What would be the outcome of the above query?

A. It produces an error because flower braces have been used.


B. It produces an error because the data types are not matching.
C. It executes successfully and introduces an 's at the end of each promo_name in the output.
D. It executes successfully and displays the literal " {'s start date was } " for each row in the output.

Answer: C

QUESTION 4
The following statements produce the same results:
DELETE FROM copy_emp;
TRUNCATE TABLE copy_emp;

A. True
B. False

Answers: B

QUESTION 5

Which three statements/commands does not cause a transaction to end?

A. COMMIT
B. SELECT
C. CREATE
D. ROLLBACK
E. SAVEPOINT

Answers: B,E

QUESTION 6

Which of the following are NOT valid operators for the WHERE clause?

A. >=
B. IS NULL
C. !=
D. IS LIKE
E. IN BETWEEN
F. <>

Answers: D, E

QUESTION 7

Indexes must be created manually and serve to speed up access to rows in a table.

A. True
B. False

Answers: B

QUESTION 8

Which statements is not true regarding the COALESCE function? (choose all that apply)

A. It can have a maximum of five expressions in a list.


B. It returns the highest NOT NULL value in the list for all rows.
C. It requires that all expressions in the list must be of the same data type.
D. It requires that at least one of the expressions in the list must have a NOT NULL value.

Answers: A, B, D

QUESTION 9

Identify the set operator guidelines.

A. The expressions in the SELECT lists must match in number.


B. Parentheses may not be used to alter the sequence of execution.
C. The data type of each column in the second query must match the data type of its corresponding
column in the first query.
D. The ORDER BY clause can be used only once in a compound query, unless a UNION ALL
operator is used.

Answers: A, C

QUESTION 10

When you use the INSERT or UPDATE command, the DEFAULT keyword saves you from hard-coding
the default value in your programs or querying the dictionary to find it.

A. True
B. False

Answer: A

QUESTION 11

Which two statements are not true regarding the USING clause in table joins? (Choose two .)

A. It can be used to join a maximum of three tables.


B. It can be used to restrict the number of columns used in a NATURAL join.
C. It can be used to access data from tables through equijoins as well as nonequijoins.
D. It can be used to join tables that have columns with the same name and compatible data types.

Answers: A, C

QUESTION 12

Evaluate the following query:

SQL> SELECT cust_name AS "NAME", cust_credit_limit/2 AS MIDPOINT,MIDPOINT+100 AS


“MAX LOWER LIMIT"
FROM customers;

The above query produces an error on execution.


What is the reason for the error?
A. An alias cannot be used in an expression.
B. The a lias NAME should not be enclosed with in double quotation marks .
C. The MIDPOINT+100 expression gives an error because CUST_CREDIT_LIMIT contains
NULL values.
D. The a lias MIDPOINT should be enclosed with in double quotation marks for the
CUST_CREDIT_LIMIT/2 expression.

Answer: A

QUESTION 13

Which two statements are true regarding views?

A. A subquery that defines a view cannot include the GROUP BY clause


B. A view is created with the subquery having the DISTINCT keyword can be updated
C. A view that is created with the subquery having the pseudo column ROWNUM keyword cannot
be updated
D. A Data Manipulation Language (DML) operation can be performed on a view that is created with
the subquery having all the NOT NULL columns of a table

Answer: C,D

QUESTION 14

Which is a valid CREATE TABLE statement?

A. CREATE TABLE EMP9$# TEST(empid number(2));


B. CREATE TABLE EMP*123 TEST(empid number(2));
C. CREATE TABLE PACKAGE TEST(packid number(2));
D. CREATE TABLE 1EMP_TEST TEST(empid number(2));

Answer: A

QUESTION 15

Which statements are not true regarding subqueries? (Choose all that apply)

A. A subquery can retrieve zero or more rows.


B. Only two subqueries can be placed at one level.
C. A subquery can be used only in SQL query statements.
D. A subquery can appear on either side of a comparison operator.
E. There is no limit on the number of subquery levels in the WHERE clause of a SELECT
statement.

Answers: B, C, E

QUESTION 16

The dictionary views that are based on the dictionary tables contain information such as:
A. Definitions of all the schema objects in the database
B. Default values for the columns
C. Integrity constraint information
D. Privileges and roles that each user has been granted
E. All of the above

Answer: E

QUESTION 17

You can use constraints to do the following:

A. Enforce rules on the data in a table whenever a row is inserted, updated, or deleted.
B. Prevent the deletion of a table.
C. Prevent the creation of a table.
D. Prevent the creation of data in a table.

Answer: A, B, D

QUESTION 18

Which of the following statements are true?

A. After a user creates an object, the user can pass along any of the available object privileges to
other users by using the GRANT statement.
B. A user can create roles by using the CREATE ROLE statement to pass along a collection of
system or object privileges to other users.
C. Users can change their own passwords.
D. Users can view the privileges granted to them and those that are granted on their objects.

Answers: A, C, D

QUESTION 19

Evaluate the following SQL statement:

SQL> SELECT cust_id, cust_last_name


FROM customers
WHERE cust_credit_limit = ALL
(select cust_credit_limit
FROM customers
WHERE cust_city ='Singapore');

Which statement is true regarding the above query if the subquery returns no rows?

A. It produces an error.
B. It executes and returns all rows of customers table.
C. It executes but returns no rows.

Answers: B
QUESTION 20

Evaluate the following SQL statement:


SQL> SELECT cust_id, cust_last_name "Last Name"
FROM customers
WHERE country_id = 10
UNION
SELECT cust_id CUST_NO, cust_last_name
FROM customers
WHERE country_id = 30;

Which ORDER BY clauses are not valid for the above query? (Choose all that apply.)

A. ORDER BY 2,1
B. ORDER BY CUST_NO
C. ORDER BY 2,cust_id
D. ORDER BY "CUST_NO"
E. ORDER BY "Last Name"

Answers: B, D

You might also like