0

databases Online Quiz - 235

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

What output will the follwing statement produce? Select NVL2(NULL,'NOT NULL', NULL) from dual?

  1. NULL

  2. NOT NULL

  3. Function NVL2 is not defined

  4. None of the above


Correct Option: A
Explanation:

To solve this question, the user needs to know the function NVL2 in SQL.

The NVL2 function in SQL returns one value if an expression is not null, or another value if it is null. The syntax for the NVL2 function is:

NVL2( expression1, expression2, expression3 )

If expression1 is not null, then NVL2 returns expression2. If expression1 is null, then NVL2 returns expression3.

In this case, expression1 is NULL, so NVL2 will return the value of expression3, which is also NULL.

Therefore, the answer is:

The Answer is: A. NULL

What is the result if two NULL values are compared to each other?

  1. TRUE

  2. FALSE

  3. Undefined

  4. NULL


Correct Option: D
  1. When a SELECT statement returns more than one row

  2. When a SELECT statement returns no rows

  3. When INTO statement is missing in the SELECT statement

  4. Both I and II


Correct Option: D
Explanation:

To answer this question, the user needs to know the basics of PL/SQL and how it handles exceptions.

A. When a SELECT statement returns more than one row: This is one of the cases where PL/SQL raises an exception. If a SELECT statement returns more than one row in a context where a single value is expected, such as in an assignment statement or a SELECT INTO statement, then PL/SQL will raise the TOO_MANY_ROWS exception.

B. When a SELECT statement returns no rows: This is another case where PL/SQL raises an exception. If a SELECT statement returns no rows in a context where a single value is expected, such as in an assignment statement or a SELECT INTO statement, then PL/SQL will raise the NO_DATA_FOUND exception.

C. When INTO statement is missing in the SELECT statement: This is not a case where PL/SQL raises an exception. If an INTO statement is missing in a SELECT statement, then a compilation error will occur, but it will not result in an exception at runtime.

D. Both I and II: This option is correct. PL/SQL raises exceptions in both cases where a SELECT statement returns more than one row (TOO_MANY_ROWS) and where a SELECT statement returns no rows (NO_DATA_FOUND).

Therefore, the correct answer is: D.

Which SELECT statement will get the result 'elloworld' from the string 'HelloWorld'?

  1. SELECT INITCAP(TRIM ('HelloWorld', 1,1)) FROM dual;

  2. SELECT SUBSTR( 'HelloWorld',1) FROM dual;

  3. SELECT LOWER(SUBSTR('HelloWorld', 1, 1) FROM dual;

  4. SELECT LOWER(TRIM ('H' FROM 'HelloWorld')) FROM dual;


Correct Option: D
Explanation:

To solve this question, the user needs to know the basics of SQL SELECT statements and string manipulation functions. The user should be familiar with the INITCAP, TRIM, SUBSTR, and LOWER functions.

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

A. SELECT INITCAP(TRIM ('HelloWorld', 1,1)) FROM dual;

This option is incorrect. The TRIM function removes characters from the beginning and end of a string. In this case, the second and third arguments of the TRIM function are incorrect. INITCAP capitalizes the first letter of a string and converts the rest of the string to lowercase. Therefore, this SELECT statement will not return the correct result.

B. SELECT SUBSTR( 'HelloWorld',1) FROM dual;

This option is incorrect. The SUBSTR function returns a substring from a given string. In this case, the function only returns the first character of the string 'HelloWorld'. Therefore, this SELECT statement will not return the correct result.

C. SELECT LOWER(SUBSTR('HelloWorld', 1, 1) FROM dual;

This option is incorrect. The SUBSTR function returns a substring from a given string. In this case, the function only returns the first character of the string 'HelloWorld'. The LOWER function converts the substring to lowercase. Therefore, this SELECT statement will not return the correct result.

D. SELECT LOWER(TRIM ('H' FROM 'HelloWorld')) FROM dual;

This option is correct. The TRIM function removes the character 'H' from the beginning of the string 'HelloWorld'. The LOWER function converts the remaining string to lowercase. Therefore, this SELECT statement will return the correct result.

The Answer is: D

  1. CASE WHEN B IS NOT NULL THEN A ELSE B

  2. CASE WHEN A IS NOT NULL THEN A ELSE B

  3. CASE WHEN A IS NOT NULL THEN B ELSE A

  4. CASE WHEN A IS NOT NULL THEN A ELSE A


Correct Option: B
  1. Both tables have NULL values.

  2. You want all matched data from both tables.

  3. You want all unmatched data from both tables.

  4. You want all unmatched data from one table.


Correct Option: C

mod(-15, 4)would return ?

  1. 15

  2. -15

  3. -3

  4. 3


Correct Option: C

instr(Tech on the net, e, -3, 2) would retrun

  1. 10

  2. 8

  3. 6

  4. 2


Correct Option: D

TRUNC(44.647, -1) would retrun ?

  1. 44.6

  2. 44

  3. 40

  4. 43


Correct Option: C
  1. Create each procedure with a distinct name followed by a semi-colon and a group name.

  2. Create each procedure with a distinct name followed by a semi-colon and a group number.

  3. Create each procedure with the same name followed by a semi-colon and a group name.

  4. Create each procedure with the same name followed by a semi-colon and a distinct number.


Correct Option: D

You have a mission critical database named MCDB1 that you want to configure for automatic failover. You have decided to utilize database mirroring. Which database mirroring operating mode should you use?

  1. High safety mode

  2. Asynchronously

  3. High performance mode

  4. Synchronously


Correct Option: A
  1. Convert the XML documents to relational data and then store them within the database

  2. Create a table that uses XML as the data type for the column that will store the XML documents.

  3. Nothing. You can not store XML documents within a SQL Server 2005 database

  4. Create a table that uses nvarchar(max) as the data type for the column that will store the XML documents


Correct Option: D

EasyYatra is a travel booking company that has a web site available for customers to view and book their vacations online. You have been hired to look after the back-end SQL Server that is used to store customer and booking information. You are creating a table called Booking to keep track of vacations booked by customers. This table will contain a computed column called Total that is derived from other columns in the table. You want to be able to create an index on this Total column to increase performance when any queries are executed using this column. To do this, you want to physically store the computed column in the table. How can this be done?

  1. Mark the computed column as PERSISTED.

  2. Define the computed column as NULL.

  3. Specify the collation for the column using COLLATE Physical.

  4. Do nothing. Computed columns are stored in the table by default.


Correct Option: A
  1. Na

  2. An

  3. fe

  4. fef


Correct Option: A

Which task can you perform using only the TO_CHAR function?

  1. convert 10 to 'TEN'

  2. convert '10' to 10

  3. convert '10' to '10'

  4. convert 'TEN' to 10


Correct Option: C

AI Explanation

To answer this question, you need to understand the TO_CHAR function in SQL.

The TO_CHAR function is used to convert a value to a character data type. It takes a value as input and returns a character representation of that value. However, it does not perform any other type conversions or transformations.

Let's go through each option to understand why it is correct or incorrect:

Option A) convert 10 to 'TEN' - This option is incorrect because the TO_CHAR function cannot convert a numeric value to a character string representing the word 'TEN'.

Option B) convert '10' to 10 - This option is incorrect because the TO_CHAR function does not perform any type conversions. It only converts a value to a character data type, so it cannot convert a character string to a numeric value.

Option C) convert '10' to '10' - This option is correct because the TO_CHAR function can be used to convert a character string to another character string. In this case, it would simply return the same character string '10'.

Option D) convert 'TEN' to 10 - This option is incorrect because the TO_CHAR function cannot convert a character string representing the word 'TEN' to a numeric value.

The correct answer is Option C) convert '10' to '10'. This option is correct because the TO_CHAR function can be used to convert a character string to another character string.

  1. The indexed column is declared as NOT NULL.

  2. The indexed columns are used in the FROM clause.

  3. The indexed columns are part of an expression.

  4. The indexed column contains a wide range of values.


Correct Option: D
- Hide questions