SQL Database Queries and Operations
Test your knowledge of SQL database operations including SELECT, INSERT, UPDATE, DELETE statements, and data manipulation functions.
Questions
Which SQL statement is used to extract data from a database?
- SELECT
- GET
- OPEN
- EXTRACT
Which SQL statement is used to update data in a database?
- SAVE
- MODIFY
- UPDATE
- SAVE AS
Which SQL statement is used to insert new data in a database?
- ADD RECORD
- ADD NEW
- INSERT
- INSERT NEW
With SQL, how do you select all the columns from a table named "Persons"?
- SELECT [all] FROM Persons ;
- SELECT *. FROM Persons ;
- SELECT *.Persons ;
- SELECT * FROM Persons ;
With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" is "Peter"?
- SELECT [all] FROM Persons WHERE FirstName='Peter' ;
- SELECT * FROM Persons WHERE FirstName='Peter' ;
- SELECT * FROM Persons WHERE FirstName LIKE 'Peter' ;
- SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter' ;
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"?
- SELECT * FROM Persons WHERE FirstName LIKE '%a';
- SELECT * FROM Persons WHERE FirstName='a' ;
- SELECT * FROM Persons WHERE FirstName LIKE 'a%' ;
- SELECT * FROM Persons WHERE FirstName='%a%;
Which SQL keyword is used to sort the result-set?
- ORDER
- SORT
- SORT BY
- ORDER BY
With SQL, how can you return all the records from a table named "Persons" sorted descending by "FirstName"?
- SELECT * FROM Persons SORT 'FirstName' DESC ;
- SELECT * FROM Persons ORDER BY FirstName DESC;
- SELECT * FROM Persons ORDER FirstName DESC ;
- SELECT * FROM Persons SORT BY 'FirstName' DESC ;
How can you change "Hansen" into "Nilsen" in the "LastName" column in the Persons table?
- UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen';
- MODIFY Persons SET LastName='Hansen' INTO LastName='Nilsen ;
- UPDATE Persons SET LastName='Hansen' INTO LastName='Nilsen' ;
- MODIFY Persons SET LastName='Nilsen' WHERE LastName='Hansen' ;
With SQL, how can you delete the records where the "FirstName" is "Peter" in the Persons Table?
- DELETE FROM Persons WHERE FirstName = 'Peter' ;
- DELETE FirstName='Peter' FROM Persons;
- DELETE ROW FirstName='Peter' FROM Persons ;
- TRUNCATE FROM Persons WHERE FirstName='Peter'
With SQL, how can you return the number of records in the "Persons" table?
- SELECT COLUMNS(*) FROM Persons ;
- SELECT COUNT() FROM Persons;
- SELECT COUNT(*) FROM Persons;
- SELECT COLUMNS() FROM Persons;