W3 SQL Flashcards
sql
What does SQL stand for?
Structured Query Language
sql
Which SQL statement is used to extract data from a database?
SELECT
sql
Which SQL statement is used to update data in a database?
UPDATE
sql
Which SQL statement is used to delete data from a database?
DELETE
sql
Which SQL statement is used to insert new data in a database?
INSERT INTO
sql
With SQL, how do you select a column named “FirstName” from a table named “Persons”?
SELECT FirstName FROM Persons
sql
With SQL, how do you select all the columns from a table named “Persons”?
SELECT * FROM Persons
sql
With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” is “Peter”?
SELECT * FROM Persons WHERE FirstName=’Peter’
sql
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%’
sql
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
True
sql
With SQL, how do you select all the records from a table named “Persons” where the “FirstName” is “Peter” and the “LastName” is “Jackson”?
SELECT * FROM Persons WHERE FirstName=’Peter’ AND LastName=’Jackson’
sql
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”?
SELECT * FROM Persons WHERE LastName BETWEEN ‘Hansen’ AND ‘Pettersen’
sql
Which SQL statement is used to return only different values?
SELECT DISTINCT
sql
Which SQL keyword is used to sort the result-set?
ORDER BY
sql
With SQL, how can you return all the records from a table named “Persons” sorted descending by “FirstName”?
SELECT * FROM Persons ORDER BY FirstName DESC
sql
With SQL, how can you insert a new record, Jimmy and Jackson, into the “Persons” table?
INSERT INTO Persons VALUES (‘Jimmy’, ‘Jackson’)
sql
With SQL, how can you insert “Olsen” as the “LastName” in the “Persons” table?
INSERT INTO Persons (LastName) VALUES (‘Olsen’)
sql
How can you change “Hansen” into “Nilsen” in the “LastName” column in the Persons table?
UPDATE Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’
sql
With SQL, how can you delete the records where the “FirstName” is “Peter” in the Persons Table?
DELETE FROM Persons WHERE FirstName = ‘Peter’