Tag: databases

Questions Related to databases

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

  1. INSERT NEW

  2. ADD NEW

  3. ADD RECORD

  4. INSERT INTO

Answer: 4

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

  1. SELECT FirstName FROM Persons

  2. EXTRACT FirstName FROM Persons

  3. SELECT Persons.FirstName

  4. SELECT * FROM Persons

Answer: 1

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

  1. COLLAPSE

  2. REMOVE

  3. DELETE

  4. TRUNCATE

Answer: 3

With SQL, how do you select all the columns from a table named 'Persons'?

  1. SELECT [all] FROM Persons

  2. SELECT * FROM Persons

  3. SELECT *.Persons

  4. SELECT Persons

Answer: 2

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 * 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'

Answer: 4

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 LIKE '%a'

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

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

Answer: 1

Which SQL statement is used to return only different values?

  1. SELECT DISTINCT

  2. SELECT DIFFERENT

  3. SELECT UNIQUE

  4. SELECT ALL

Answer: 1

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

  1. ORDER

  2. ORDER BY

  3. SORT BY

  4. SORT

Answer: 2

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

  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

Answer: 2

What is the output? SELECT SUBSTRING('123456', 0, 3)

  1. 123

  2. 12

  3. 123456

  4. 456

Answer: 2