Chủ Nhật, 21 tháng 9, 2014

SQL Quiz - W3School

SQL Quiz - W3School


---o0o---


1. Q: What does SQL stand for?

A: Structured Query Language

2. Q: Which SQL statement is used to extract data from a database?

A: SELECT

3. Q: Which SQL statement is used to update data in a database?

A: UPDATE

4. Q: Which SQL statement is used to delete data from a database?

A: DELETE

5. Q: Which SQL statement is used to insert new data in a database?

A: INSERT INTO

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

A: SELECT FirstName FROM Persons

7. Q: With SQL, how do you select all the columns from a table named "Persons"?

A: SELECT * FROM Persons

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

A: SELECT * FROM Persons WHERE FirstName='Peter'

9. Q: 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"?

A: SELECT * FROM Persons WHERE FirstName LIKE 'a%'

10. Q: 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

A: True

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

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

12. Q: 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"?

A: SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'

13. Q: Which SQL statement is used to return only different values?

A: SELECT UNIQUE

14. Q: Which SQL keyword is used to sort the result-set?

A: ORDER BY

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

A: SELECT * FROM Persons ORDER BY FirstName DESC

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

A: INSERT INTO Persons VALUES ('Jimmy', 'Jackson')

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

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

18. Q: How can you change "Hansen" into "Nilsen" in the "LastName" column in the Persons table?

A: UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'

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

A: DELETE FROM Persons WHERE FirstName = 'Peter'

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

A: SELECT COUNT(*) FROM Persons

Không có nhận xét nào:

Đăng nhận xét