0

databases Online Quiz - 226

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

Which section of a PL/SQL block commences with the BEGIN keyword?

  1. Exception

  2. Executable

  3. Declarative

  4. Anonymous


Correct Option: B

Evaluate the SQL statement: SELECT LPAD(salary,10,*) FROM EMP WHERE EMP_ID = 1001; If the employee with the EMP_ID 1001 has a salary of 17000, what is displayed?

  1. 17000.00

  2. 17000*****

  3. **17000.00

  4. An error statement


Correct Option: D

AI Explanation

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

The SQL statement is as follows:

SELECT LPAD(salary, 10, *) FROM EMP WHERE EMP_ID = 1001;

The LPAD function in SQL is used to pad a string or number with a specific character to a specified length. In this case, the salary column is being padded with "*" characters to a length of 10.

The WHERE clause specifies that only the row where EMP_ID is equal to 1001 should be selected.

Given that the employee with EMP_ID 1001 has a salary of 17000, let's evaluate the statement:

SELECT LPAD(17000, 10, *) FROM EMP WHERE EMP_ID = 1001;

The LPAD function will pad the salary value of 17000 with "*" characters to a length of 10:

17000*****

Hence, the correct answer is D - An error statement. This is because the SQL statement is syntactically incorrect due to the use of an asterisk (*) as the padding character instead of a valid character or string.

There are also multiple-column subqueries: Queries that return more than one column from the inner SELECT statement.(T/F)

  1. True

  2. False


Correct Option: A

What is the output in RR format for following dates Date Specified :27-Oct-1995

  1. 2017

  2. 1917

  3. 1900

  4. 2000


Correct Option: B

The outer and inner queries can get data from different tables?

  1. True

  2. False


Correct Option: A
  1. binary data up to 4 gigabytes

  2. character data up to 4 gigabytes

  3. a hexadecimal string representing the unique address of a row in its table

  4. raw binary data of variable length up to 2 gigabytes


Correct Option: C

What will be the output of following Select 8 from Emp ? Emp table has 10 rows

  1. No Rows returned

  2. 10 rows of Emp table

  3. Error

  4. 8 is displayed 10 times


Correct Option: D

Can we abbreviate keywords across lines?e.g. DESCRIBE

  1. True

  2. False


Correct Option: B

Is Century Information is recorded when Oracle data base stores the DATE internally into a table?

  1. True

  2. False


Correct Option: A

What is the correct use of the Trunc command on a date?

  1. TRUNC=To_Date('09-Jan-02,DD-MON-YY,'YEAR',"Date" from Dual;

  2. Select TRUNC(To_Date('09-Jan-02,DD-MON-YY,YEAR')) "DATE" from Dual;

  3. Date =TRUNC(To_DATE('09-Jan-02','DD-MON-YY'),'YEAR'),'YEAR)"DATE: from DUAL;

  4. SELECT TRUNC(TO_DATE('12-Feb-99','DD-MON-YY'), 'YEAR') "Date " FROM DUAL;


Correct Option: D

Which type of join should be written to perform an outer join of tables A and B that returns all rows from B?

  1. Any outer join

  2. A left outer join

  3. A cross join

  4. A right outer join


Correct Option: D

How many join conditions should be there to avoid a Cartesian Join for joining three tables?

  1. 1

  2. 2

  3. 3

  4. None of these


Correct Option: D

Examine the code given below: SELECT employee_id FROM employees WHERE commission_pct=.5 OR salary > 23000 Which of the following statement is correct with regard to this code?

  1. It returns employees who have 50% of the salary greater than $23,000:

  2. It returns employees who have 50% commission rate or salary greater than $23,000:

  3. It returns employees who have 50% of salary less than $23,000:

  4. None of the above


Correct Option: B

Which of the following tasks can be performed by using the TO_CHAR function?

  1. Convert '10'to 10

  2. Convert 10 to '10'

  3. Convert 'TEN' to 10

  4. Convert a date to a character expression


Correct Option: B,D

Which of the following SELECT statements will get the result 'elloworld' from the string 'HelloWorld'?

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

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

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

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


Correct Option: D

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) SELECT SUBSTR ('HelloWorld',1) FROM dual; This option selects a substring from the string 'HelloWorld' starting from the first character. So, the result will be 'H'. This option is incorrect.

Option B) SELECT LOWER (SUBSTR ('HellowWorld', 2,1) FROM dual; This option selects a substring from the string 'HellowWorld' starting from the second character and with a length of 1. The result will be 'e'. This option is incorrect.

Option C) SELECT LOWER (SUBSTR('HellowWorld', 2,1) FROM dual; This option is the same as option B, with a minor typo in the spelling of 'HelloWorld'. The result will also be 'e'. This option is incorrect.

Option D) SELECT LOWER (TRIM ('H' FROM 'Hello World')) FROM dual; This option trims the character 'H' from the string 'Hello World', resulting in 'ello World'. Then, it converts the remaining string to lowercase using the LOWER function. The final result will be 'elloworld'. This option is correct.

The correct answer is D. This option is correct because it trims the 'H' from the string and converts the remaining string to lowercase, resulting in 'elloworld'.

Where is the GROUP BY clause statement placed in a SELECT statement that includes a WHERE clause?

  1. Immediately after the SELECT clause

  2. Before the WHERE clause

  3. After the ORDER BY clause

  4. After the WHERE clause


Correct Option: D

Evaluate the following SQL statement: SELECT ROUND (TRUNC (MOD (1600, 10),-1), 2) FROM dual; What will be displayed?

  1. 0

  2. 1

  3. 0.00

  4. An error statement


Correct Option: A
Explanation:

To evaluate the SQL statement, we need to understand the functions ROUND, TRUNC and MOD.

ROUND: rounds a number to a specified number of decimal places. If the second argument is negative, it rounds to the left of the decimal point. For example, ROUND(123.456, 2) = 123.46, ROUND(123.456, -1) = 120. TRUNC: truncates a number to a specified number of decimal places. If the second argument is negative, it truncates to the left of the decimal point. For example, TRUNC(123.456, 2) = 123.45, TRUNC(123.456, -1) = 120. MOD: returns the remainder of a division operation. For example, MOD(7, 3) = 1, MOD(1600, 10) = 0. Using these functions, we can evaluate the SQL statement step by step:

MOD(1600,10) returns 0, since there is no remainder when dividing 1600 by 10. TRUNC(0,-1) returns 0, since there is nothing to truncate to the left of the decimal point. ROUND(0,2) returns 0, since there is nothing to round to the right of the decimal point. Therefore, the final result displayed by the SQL statement is 0.

- Hide questions