0

databases Online Quiz - 114

Description: databases Online Quiz - 114
Number of Questions: 20
Created by:
Tags: databases
Attempted 0/20 Correct 0 Score 0

Which clause in a query limits the rows selected?

  1. ORDER BY

  2. FROM

  3. SELECT

  4. WHERE


Correct Option: D

PL/SQL blocks may be nested within exception block.

  1. True

  2. False


Correct Option: A

The following block statement will run successfully SCOTT.EMP.EMPNO := 1234;

  1. True

  2. False


Correct Option: B

5 + NULL evaluates to 5 and ‘PL/’ || NULL || ‘SQL’ evaluates to ‘PL/SQL’

  1. True

  2. False


Correct Option: B

what will be the output of the following block: set serveroutput on; declare a int; b int; begin a:=NULL; b:=NULL; if a< b then dbms_output.put_line('y'); else dbms_output.put_line('n'); end if; end;

  1. y

  2. n

  3. error

  4. no output


Correct Option: B

AI Explanation

To answer this question, let's go through the code step by step:

  1. The statement set serveroutput on; enables the output display in Oracle.

  2. The keyword declare is used to declare variables within the block.

  3. The variables a and b of type int are declared.

  4. The value of a and b are set to NULL.

  5. The if statement checks if a is less than b. Since both a and b are NULL, the condition evaluates to NULL.

  6. In Oracle, NULL is considered an unknown value. When comparing NULL with any other value, the result is always NULL.

  7. The else part of the if statement is executed because the condition is not satisfied. It prints 'n' using the dbms_output.put_line function.

  8. Finally, the end if; marks the end of the if statement.

Based on the above explanation, the correct answer is:

Option B) n

which statement is used to break a loop in pl/sql

  1. exit

  2. break

  3. stop

  4. continue


Correct Option: A

DUP_VAL_ON_INDEX corressponds to which of the following error.

  1. ORA-01427

  2. ORA-01476

  3. ORA-00001

  4. ORA-01001


Correct Option: C
  1. fox pro

  2. oracle

  3. db2

  4. sql server


Correct Option: B

Which of the following statements contains an error?

  1. SELECT * FROM emp WHERE empid = 493945;

  2. SELECT empid FROM emp WHERE empid= 493945;

  3. SELECT empid FROM emp;

  4. SELECT empid WHERE empid = 56949 AND lastname = ‘SMITH’;


Correct Option: D
Explanation:

To solve this question, the user needs to know the basic syntax of SQL queries. The user must evaluate each query to identify the one that contains an error.

Now, let's go through each option and explain why it is right or wrong:

A. SELECT * FROM emp WHERE empid = 493945;

This statement is correct. It selects all columns from the "emp" table where the "empid" column has a value of 493945.

B. SELECT empid FROM emp WHERE empid= 493945;

This statement is correct. It selects the "empid" column from the "emp" table where the "empid" column has a value of 493945.

C. SELECT empid FROM emp;

This statement is correct. It selects the "empid" column from the "emp" table without any filtering conditions.

D. SELECT empid WHERE empid = 56949 AND lastname = ‘SMITH’;

This statement contains an error. It is missing the "FROM" keyword, which is required to specify the table from which the data should be selected. The correct statement would be "SELECT empid FROM emp WHERE empid = 56949 AND lastname = 'SMITH'".

Therefore, the answer is:

The Answer is: D

The user issues the following statement. What will be displayed if the EMPID selected is 60494? SELECT DECODE(empid,38475, “Terminated”,60494, “LOA”, “ACTIVE”) FROM emp;

  1. ACTIVE

  2. LOA

  3. TERMINATED

  4. 38475


Correct Option: B

AI Explanation

To answer this question, let's analyze the given SQL statement:

SELECT DECODE(empid,38475, "Terminated",60494, "LOA", "ACTIVE") FROM emp;

The DECODE function in SQL is used to compare an expression (in this case, empid) with a list of values and return a corresponding result.

In the given statement, the empid is compared to three values: 38475, 60494, and the default value "ACTIVE".

If the empid matches 38475, the result will be "Terminated". If the empid matches 60494, the result will be "LOA". If the empid does not match any of these values, the result will be "ACTIVE".

In this case, the empid selected is 60494. Therefore, the result of the statement will be "LOA".

So, the correct answer is B) LOA.

The default character for specifying runtime variables in SELECT statements is :-

  1. percentage sign

  2. Quotation marks

  3. Ampersand

  4. Ellipses


Correct Option: C
Explanation:

To solve this question, the user needs to be aware of the syntax used to specify runtime variables in SQL SELECT statements.

The correct answer is:

C. Ampersand

Explanation: In SQL SELECT statements, runtime variables are specified using the ampersand (&) character followed by the variable name. For example, to specify a variable named "dept_name", you would use "&dept_name" in the SELECT statement. This allows users to enter a value for the variable at runtime, rather than hard-coding the value into the query.

Option A (percentage sign) is incorrect, as this character is commonly used as a wildcard operator in SQL, but not for specifying runtime variables.

Option B (quotation marks) is also incorrect, as quotation marks are used to delimit string literals in SQL, but not for specifying runtime variables.

Option D (ellipses) is incorrect, as ellipses are not used in SQL syntax for specifying runtime variables.

Therefore, the correct answer is:

The Answer is: C. Ampersand

SELECT (TO_CHAR(NVL(SQRT(59483), “INVALID”)) FROM DUAL is a valid SQL statement.

  1. True

  2. False


Correct Option: B

MAXVALUE is a valid parameter for sequence creation.

  1. True

  2. False


Correct Option: A
  1. No effect

  2. The index will be rendered invalid

  3. The index will be dropped

  4. The index will contain NULL values.


Correct Option: C
- Hide questions