0

databases Online Quiz - 217

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

The OR operator displays a record if ANY conditions listed are true. The AND operator displays a record if ALL of the conditions listed are true

  1. True

  2. False


Correct Option: B

AI Explanation

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

Option A) True - This option is incorrect because the OR operator displays a record if at least one of the conditions listed is true, not any condition.

Option B) False - This option is correct because the AND operator displays a record only if all of the conditions listed are true.

The correct answer is B) False. This option is correct because the statement correctly explains the behavior of the AND operator, but not the OR operator. The OR operator displays a record if at least one of the conditions listed is true, not any condition.

With SQL, how can you return all the records from a table named "Persons" sorted descending by "FirstName"?

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

  2. SELECT * FROM Persons SORT 'FirstName' DESC

  3. SELECT * FROM Persons ORDER BY FirstName DESC

  4. SELECT * FROM Persons ORDER FirstName DESC


Correct Option: C

AI Explanation

To return all the records from a table named "Persons" sorted descending by "FirstName" in SQL, you can use the "ORDER BY" clause.

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

Option A) SELECT * FROM Persons SORT BY 'FirstName' DESC - This option is incorrect because the correct keyword to sort in SQL is "ORDER BY" and not "SORT BY".

Option B) SELECT * FROM Persons SORT 'FirstName' DESC - This option is incorrect because the correct keyword to sort in SQL is "ORDER BY" and not "SORT". Additionally, the syntax for specifying the column to sort by should not be enclosed in single quotes ('FirstName').

Option C) SELECT * FROM Persons ORDER BY FirstName DESC - This option is correct. It uses the "ORDER BY" clause to sort the records in descending order based on the "FirstName" column.

Option D) SELECT * FROM Persons ORDER FirstName DESC - This option is incorrect because the correct syntax to specify the column to sort by is "ORDER BY" followed by the column name. Here, the "FirstName" column is missing the "BY" keyword.

The correct answer is C. This option is correct because it uses the "ORDER BY" clause with the correct syntax to sort the records in descending order by the "FirstName" column.

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

  1. OPEN

  2. EXTRACT

  3. SELECT

  4. GET


Correct Option: C

Which SQL statement is used to update data in a database?

  1. UPDATE

  2. MODIFY

  3. SAVE

  4. SAVE AS


Correct Option: A

Which SQL statement is used to insert new data in a database?

  1. ADD NEW

  2. INSERT INTO

  3. ADD RECORD

  4. INSERT NEW


Correct Option: B

What does SQL stand for?

  1. Strong Question Language

  2. Structured Query Language

  3. Structured Question Language

  4. Strong Query Language


Correct Option: B
  1. SELECT * FROM Persons

  2. SELECT [all] FROM Persons

  3. SELECT Persons

  4. SELECT FROM Persons


Correct Option: A

Which SQL statement is used to return only different values?

  1. SELECT DIFFERENT

  2. SELECT UNIQUE

  3. SELECT DISTINCT

  4. SELECT EXACT


Correct Option: C

With SQL, how can you insert a new record into the "Persons" table?

  1. INSERT INTO Persons VALUES ('Jimmy', 'Jackson')

  2. INSERT VALUES ('Jimmy', 'Jackson') INTO Persons

  3. INSERT ('Jimmy', 'Jackson') INTO Persons

  4. INSERT VALUES ('Jimmy', 'Jackson')


Correct Option: A

With SQL, how can you insert "Olsen" as the "LastName" in the "Persons" table?

  1. INSERT INTO Persons (LastName) VALUES ('Olsen')

  2. INSERT ('Olsen') INTO Persons (LastName)

  3. INSERT INTO Persons ('Olsen') INTO LastName

  4. INSERT INTO Persons ('Olsen')


Correct Option: A

AI Explanation

To insert the value "Olsen" as the "LastName" in the "Persons" table using SQL, you can use the following statement:

A. INSERT INTO Persons (LastName) VALUES ('Olsen')

Explanation: Option A is the correct answer because it follows the correct syntax for the INSERT statement in SQL. The statement starts with "INSERT INTO" followed by the table name "Persons". Then, in parentheses, you specify the column name "LastName" where you want to insert the value. Finally, the keyword "VALUES" is used to specify the value you want to insert, which is 'Olsen' in this case.

With SQL, how can you delete the records where the "FirstName" is "Peter" in the Persons Table?

  1. DELETE ROW FirstName='Peter' FROM Persons

  2. DELETE FROM Persons WHERE FirstName = 'Peter'

  3. DELETE FirstName='Peter' FROM Persons

  4. REMOVE FROM Persons WHERE FirstName = 'Peter'


Correct Option: B

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

  1. DELETE

  2. COLLAPSE

  3. REMOVE

  4. ERASE


Correct Option: A

With SQL, how do you select a column named "FirstName" from a table named "Persons"?

  1. EXTRACT FirstName FROM Persons

  2. SELECT FirstName FROM Persons

  3. SELECT Persons.FirstName

  4. SELECT * FROM Persons


Correct Option: B

With SQL, how do you select all the records from a table named "Persons" where the "FirstName" is "Peter" and the "LastName" is "Jackson"?

  1. SELECT * FROM Persons WHERE FirstName='Peter' AND LastName='Jackson'

  2. SELECT FirstName='Peter', LastName='Jackson' FROM Persons

  3. SELECT * FROM Persons WHERE FirstName<>'Peter' AND LastName<>'Jackson'

  4. SELECT * FROM Persons WHERE FirstName='Jackson' AND LastName='Peter'


Correct Option: A

AI Explanation

To select all the records from a table named "Persons" where the "FirstName" is "Peter" and the "LastName" is "Jackson", you would use the SQL query:

A. SELECT * FROM Persons WHERE FirstName='Peter' AND LastName='Jackson'

Explanation: Option A) SELECT * FROM Persons WHERE FirstName='Peter' AND LastName='Jackson' - This option is correct because it uses the "SELECT" statement to retrieve all columns ("*") from the "Persons" table where the "FirstName" is equal to "Peter" and the "LastName" is equal to "Jackson".

Option B) SELECT FirstName='Peter', LastName='Jackson' FROM Persons - This option is incorrect because it uses the "SELECT" statement incorrectly. The column names should be specified after the "SELECT" keyword, not the values.

Option C) SELECT * FROM Persons WHERE FirstName<>'Peter' AND LastName<>'Jackson' - This option is incorrect because it uses the "NOT EQUAL TO" operator "<>" instead of the "EQUAL TO" operator "=" to filter the records by "FirstName" and "LastName".

Option D) SELECT * FROM Persons WHERE FirstName='Jackson' AND LastName='Peter' - This option is incorrect because it swaps the values for "FirstName" and "LastName" in the query. The correct query should be "FirstName='Peter' AND LastName='Jackson'".

Therefore, the correct answer is A) SELECT * FROM Persons WHERE FirstName='Peter' AND LastName='Jackson'.

With SQL, how do you select all the records from a table named "Persons" where the "LastName" is alphabetically between (and including) "Hansen" and "Pettersen"?

  1. SELECT * FROM Persons WHERE LastName>'Hansen' AND LastName

  2. SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'

  3. SELECT LastName>'Hansen' AND LastName

  4. SELECT LastName<>'Hansen' AND LastName<>'Pettersen' FROM Persons


Correct Option: B

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

  1. SORT BY

  2. SORT

  3. ORDER

  4. ORDER BY


Correct Option: D

How can you change "Hansen" into "Nilsen" in the "LastName" column in the Persons table?

  1. MODIFY Persons SET LastName='Nilsen' WHERE LastName='Hansen'

  2. MODIFY Persons SET LastName='Hansen' INTO LastName='Nilsen

  3. UPDATE Persons SET LastName='Hansen' INTO LastName='Nilsen'

  4. UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'


Correct Option: D

With SQL, how can you return the number of records in the "Persons" table?

  1. SELECT COUNT(*) FROM Persons

  2. SELECT COLUMNS(*) FROM Persons

  3. SELECT COLUMNS() FROM Persons

  4. SELECT COUNT() FROM Persons


Correct Option: A

With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" is "Peter"?

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

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

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

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


Correct Option: D

With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" starts with an "a"?

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

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

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

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


Correct Option: D
- Hide questions