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

The INTO clause is mandatory for SELECT statements within PL/SQL blocks.

  1. True

  2. False


Correct Option: B

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 is the concatenation operator in dbms_output.put_line() function

  1. +

  2. ||

  3. .


Correct Option: C

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

  1. exit

  2. break

  3. stop

  4. continue


Correct Option: A

which of the following lines is invalid: FOR i IN 1…256 LOOP --Line 1 x := x + i ; --Line 2 i := I + 5; --Line 3 END LOOP; --Line 4

  1. line 1

  2. line 2

  3. line 3

  4. line 4


Correct Option: C

which of the following is not an explicit cursor attribute

  1. %notfound

  2. %rowcount

  3. %isopen

  4. %isclose


Correct Option: D

AI Explanation

To answer this question, we need to understand the concept of explicit cursor attributes in Oracle.

Explicit cursors are used to retrieve and manipulate data from a query. They have certain attributes that can provide information about the cursor. The available explicit cursor attributes in Oracle are:

A) %NOTFOUND - This attribute returns TRUE if the last fetch did not return a row, and FALSE otherwise.

B) %ROWCOUNT - This attribute returns the number of rows fetched so far from the cursor.

C) %ISOPEN - This attribute returns TRUE if the cursor is open, and FALSE otherwise.

D) %ISCLOSE - This attribute is not a valid explicit cursor attribute in Oracle. Therefore, option D is the correct answer.

The correct answer is D) %ISCLOSE, as it is not an explicit cursor attribute in Oracle.

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

Which Database is oldest database in world ?

  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

Creating a foreign-key constraint between columns of two tables defined with two different datatypes will produce an error.

  1. True

  2. False


Correct Option: A

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

  1. True

  2. False


Correct Option: B

Which function below can best be categorized as similar in function to an IF-THEN-ELSE statement?

  1. NEW_TIME

  2. Decode

  3. ROWIDTOCHAR

  4. SQRT


Correct Option: B

MAXVALUE is a valid parameter for sequence creation.

  1. True

  2. False


Correct Option: A

Dropping a table has which of the following effects on a nonunique index created for the table?

  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

AI Explanation

To answer this question, we need to understand what happens to a nonunique index when a table is dropped.

Option A) No effect - This option is incorrect because dropping a table does have an effect on the index.

Option B) The index will be rendered invalid - This option is incorrect. When a table is dropped, the index is not rendered invalid. It is either dropped or remains intact.

Option C) The index will be dropped - This option is correct. When a table is dropped, all associated indexes are also dropped. This includes nonunique indexes created for the table.

Option D) The index will contain NULL values - This option is incorrect. Dropping a table does not affect the existing values in the index. Instead, the index itself is either dropped or remains intact.

The correct answer is C) The index will be dropped. This option is correct because when a table is dropped, all associated indexes, including nonunique indexes, are also dropped.

- Hide questions