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

Which SQL statement is used to delete data from a database?

  1. COLLAPSE

  2. REMOVE

  3. DELETE

  4. TRUNCATE


Correct Option: C
  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
  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 is the output? SELECT SUBSTRING('123456', 0, 3)

  1. 123

  2. 12

  3. 123456

  4. 456


Correct Option: B

AI Explanation

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

The SUBSTRING function is used to extract a substring from a given string. It takes three arguments: the input string, the starting position, and the length of the substring to be extracted.

In this case, the input string is '123456'. The starting position is 0, and the length is 3.

Using these arguments, the SUBSTRING function will extract a substring starting from the 0th position (which is the first character) with a length of 3 characters.

So, the output of the SUBSTRING('123456', 0, 3) statement will be '12'.

Therefore, the correct answer is B) 12.

  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.

  1. By value

  2. By reference

  3. By type

  4. none of the above


Correct Option: A
  1. Real abstarct clustersl

  2. Real application cursors

  3. Real application clusters

  4. none of the above


Correct Option: A
  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

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


Correct Option: D
- Hide questions