0

databases Online Quiz - 243

Description: databases Online Quiz - 243
Number of Questions: 22
Created by:
Tags: databases
Attempted 0/22 Correct 0 Score 0
  1. INSERT NEW

  2. ADD NEW

  3. ADD RECORD

  4. INSERT INTO


Correct Option: D
  1. SELECT FirstName FROM Persons

  2. EXTRACT FirstName FROM Persons

  3. SELECT Persons.FirstName

  4. SELECT * FROM Persons


Correct Option: A
  1. SELECT [all] FROM Persons

  2. SELECT * FROM Persons

  3. SELECT *.Persons

  4. SELECT Persons


Correct Option: B
Explanation:

To select all the columns from a table named 'Persons' using SQL, the user needs to use the following query:

B. SELECT * FROM Persons

Option A is incorrect because the SQL keyword for selecting all columns is not 'all,' but rather '*'.

Option C is incorrect because the '*' should come before the table name, and not after it.

Option D is incorrect because 'Persons' alone does not specify which columns to select from the table.

Therefore, the correct answer is option B.

  1. SELECT * FROM Persons WHERE FirstName <> 'Peter'

  2. SELECT [all] FROM Persons WHERE FirstName='Peter'

  3. SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter'

  4. SELECT * FROM Persons WHERE FirstName='Peter'


Correct Option: D
Explanation:

To select all the records from the table named 'Persons' where the value of the column 'FirstName' is 'Peter', the correct SQL query is:

D. SELECT * FROM Persons WHERE FirstName='Peter'

Let's go through each option and explain why the other options are incorrect:

A. SELECT * FROM Persons WHERE FirstName <> 'Peter' This query selects all records where the 'FirstName' column is not equal to 'Peter'. It is the opposite of what we want, so this option is incorrect.

B. SELECT [all] FROM Persons WHERE FirstName='Peter' The use of '[all]' is not necessary in this query. It should be replaced with '*' to select all columns. Additionally, the operator '=' should be used instead of 'LIKE' since we are looking for an exact match. Therefore, this option is incorrect.

C. SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter' The 'LIKE' operator is used for pattern matching and allows the use of wildcards (% or _). Since we are looking for an exact match of 'Peter', the '=' operator should be used instead. Therefore, this option is incorrect.

D. SELECT * FROM Persons WHERE FirstName='Peter' This option correctly selects all records from the 'Persons' table where the 'FirstName' column is equal to 'Peter'.

So, the correct answer is: D. SELECT * FROM Persons WHERE FirstName='Peter'

  1. SELECT * FROM Persons WHERE FirstName LIKE 'a%'

  2. SELECT * FROM Persons WHERE FirstName LIKE '%a'

  3. SELECT * FROM Persons WHERE FirstName='a'

  4. SELECT * FROM Persons WHERE FirstName='%a%'


Correct Option: A
  1. SELECT DISTINCT

  2. SELECT DIFFERENT

  3. SELECT UNIQUE

  4. SELECT ALL


Correct Option: A

Which SQL keyword is used to sort the result-set?

  1. ORDER

  2. ORDER BY

  3. SORT BY

  4. SORT


Correct Option: B

AI Explanation

To answer this question, you need to understand how to sort the result-set in SQL.

Option A) ORDER - This option is incorrect because the keyword "ORDER" alone is not used to sort the result-set. It needs to be combined with another keyword.

Option B) ORDER BY - This option is correct. The "ORDER BY" keyword is used in SQL to sort the result-set in ascending or descending order based on one or more columns.

Option C) SORT BY - This option is incorrect because "SORT BY" is not a valid keyword in SQL for sorting the result-set.

Option D) SORT - This option is incorrect because "SORT" is not a valid keyword in SQL for sorting the result-set.

The correct answer is B) ORDER BY. This option is correct because the "ORDER BY" keyword is used to sort the result-set in SQL.

  1. SELECT * FROM Persons ORDER FirstName DESC

  2. SELECT * FROM Persons ORDER BY FirstName DESC

  3. SELECT * FROM Persons SORT BY 'FirstName' DESC

  4. SELECT * FROM Persons SORT 'FirstName' DESC


Correct Option: B
Explanation:

To solve this question, the user needs to know SQL syntax and the concept of sorting query results in a descending order based on a specific column.

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

A. SELECT * FROM Persons ORDER FirstName DESC This option is incorrect because the correct syntax for sorting query results in SQL requires the use of the "ORDER BY" clause followed by the column name to sort by, and then the keyword "DESC" to specify descending order. Therefore, the correct syntax should be "ORDER BY FirstName DESC" instead of "ORDER FirstName DESC".

B. SELECT * FROM Persons ORDER BY FirstName DESC This option is correct. The "ORDER BY" clause is used to sort the query results based on a specific column. In this case, we want to sort the results in descending order based on the "FirstName" column. Therefore, the correct syntax is "ORDER BY FirstName DESC".

C. SELECT * FROM Persons SORT BY 'FirstName' DESC This option is incorrect because there is no "SORT" keyword in SQL. The correct keyword to use is "ORDER BY". Additionally, the column name should not be enclosed in single quotes. Therefore, the correct syntax should be "ORDER BY FirstName DESC" instead of "SORT BY 'FirstName' DESC".

D. SELECT * FROM Persons SORT 'FirstName' DESC This option is incorrect because the correct keyword to use for sorting query results in SQL is "ORDER BY" rather than "SORT". Additionally, the column name should not be enclosed in single quotes. Therefore, the correct syntax should be "ORDER BY FirstName DESC" instead of "SORT 'FirstName' DESC".

The Answer is: B

What would be the output of the code below in SQL Server 2005 and earlier versions? declare @d date select @d = '09/09/2008' select @d

  1. 09/09/2008

  2. 09-09-2008 00:00:00:000

  3. Error Message

  4. None of the above


Correct Option: C

AI Explanation

To answer this question, you need to understand how SQL Server 2005 and earlier versions handle the date data type.

In SQL Server 2005 and earlier versions, the date data type is not available. Instead, you can use the datetime data type to store both date and time values.

In the given code, the variable @d is declared as a date type. However, the value assigned to it is a string '09/09/2008'.

Since the date data type is not available in SQL Server 2005 and earlier versions, trying to assign a string value to a date variable will result in an error.

Therefore, the correct answer is C) Error Message.

what is the len of @c? declare @c varchar(8000) set @c = N'hello' + replicate('-',8000) print len(@c) print @c

  1. 8000

  2. 4000

  3. 4005

  4. 5


Correct Option: B

AI Explanation

To determine the length of the variable @c, we need to understand how the LEN() function works in SQL.

In SQL, the LEN() function is used to return the number of characters in a string. It counts the number of characters, including spaces and special characters.

In the given code snippet, the variable @c is declared as a varchar(8000). This means it can hold a maximum of 8000 characters.

The code then sets the value of @c to N'hello' + replicate('-',8000). Here, replicate('-',8000) is used to repeat the dash symbol "-" 8000 times. The resulting string is concatenated with the string "hello".

Since the LEN() function counts the number of characters in a string, it will count all the characters in @c, including the "hello" string and the repeated dashes.

Therefore, the length of @c will be the sum of the length of "hello" (5 characters) and the length of the repeated dashes (8000 characters).

So the correct answer is:

B. 4000

Which of the following SQL functions can operate on any datatype?

  1. to_char

  2. max

  3. rollup

  4. cube


Correct Option: A

AI Explanation

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

Option A) to_char - This option is correct because the to_char function in SQL can operate on any datatype. It is used to convert a value of any datatype to a character string.

Option B) max - This option is incorrect because the max function in SQL is used to return the maximum value of a specified column. It operates on numeric data types, not any datatype.

Option C) rollup - This option is incorrect because the rollup function in SQL is used to generate subtotals and grand totals in a result set. It operates on grouping sets, not any datatype.

Option D) cube - This option is incorrect because the cube function in SQL is used to generate all possible combinations of a specified set of expressions. It operates on grouping sets, not any datatype.

The correct answer is Option A) to_char. This option is correct because the to_char function can operate on any datatype and convert it to a character string.

Which Oracle access method is the fastest way for Oracle to retrieve a single row?

  1. Primary key access

  2. Full table scan

  3. Access via unique index

  4. Table access by ROWID

  5. None of the above


Correct Option: A

Which command will delete all data from a table and will not write to the rollback segment?

  1. DROP

  2. DELETE

  3. TRUNCATE

  4. REMOVE

  5. NONE OF THE ABOVE


Correct Option: A

AI Explanation

To answer this question, you need to understand the differences between the commands DROP, DELETE, and TRUNCATE in the context of deleting data from a table.

Option A) DROP - This option is incorrect because the DROP command is used to delete an entire table or database object, including its structure. It does not specifically delete data from a table without affecting the rollback segment.

Option B) DELETE - This option is incorrect because the DELETE command is used to delete specific rows from a table based on a condition. It does write to the rollback segment to allow for a rollback operation if needed.

Option C) TRUNCATE - This option is correct because the TRUNCATE command is used to delete all data from a table, but it does not write to the rollback segment. TRUNCATE is a DDL (Data Definition Language) command that is faster than DELETE because it deallocates the data pages and resets the highwater mark, freeing the space for reuse.

Option D) REMOVE - This option is incorrect because the REMOVE command is not a valid command in most database systems.

Option E) NONE OF THE ABOVE - This option is incorrect because option C (TRUNCATE) is the correct answer.

The correct answer is C) TRUNCATE. This option is correct because it deletes all data from a table without writing to the rollback segment.

What is the default behaviour of OUT parameter mode in PL/SQL

  1. By value

  2. By reference

  3. By type

  4. none of the above


Correct Option: A

What is RAC

  1. Real abstarct clustersl

  2. Real application cursors

  3. Real application clusters

  4. none of the above


Correct Option: A

Which of the following SQL functions can operate on any datatype?

  1. to_char

  2. max

  3. cube

  4. rollup


Correct Option: B
Explanation:

To answer this question, the user needs to have knowledge of SQL functions.

A. to_char: This function is used to convert a number or date to a string. It cannot operate on any datatype.

B. max: This function returns the maximum value in a set of values. It can operate on any datatype.

C. cube: This function is used to generate a result set that represents the subtotals and grand totals of the selected columns. It cannot operate on any datatype.

D. rollup: This function is used to generate a result set that represents the subtotals of the selected columns. It cannot operate on any datatype.

Therefore, the correct answer is:

The Answer is: B. max

  1. Primary key access

  2. Full table scan

  3. Access via unique index

  4. Table access by ROWID


Correct Option: D
- Hide questions