W3 SQL Flashcards

(48 cards)

1
Q

sql

What does SQL stand for?

A

Structured Query Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

sql

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

A

SELECT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

sql

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

A

UPDATE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

sql

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

A

DELETE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

sql

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

A

INSERT INTO

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

sql

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

A

SELECT FirstName FROM Persons

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

sql

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

A

SELECT * FROM Persons

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

sql

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’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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”?

A

SELECT * FROM Persons WHERE FirstName LIKE ‘a%’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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”?

A

SELECT * FROM Persons WHERE FirstName=’Peter’ AND LastName=’Jackson’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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”?

A

SELECT * FROM Persons WHERE LastName BETWEEN ‘Hansen’ AND ‘Pettersen’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

sql

Which SQL statement is used to return only different values?

A

SELECT DISTINCT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

sql

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

A

ORDER BY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

sql

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

sql

With SQL, how can you insert a new record, Jimmy and Jackson, into the “Persons” table?

A

INSERT INTO Persons VALUES (‘Jimmy’, ‘Jackson’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

sql

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

A

INSERT INTO Persons (LastName) VALUES (‘Olsen’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

sql

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

A

UPDATE Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

sql

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

A

DELETE FROM Persons WHERE FirstName = ‘Peter’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

sql

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

A

SELECT COUNT(*) FROM Persons

21
Q

sql

What is the most common type of join?

22
Q

sql

Which operator is used to select values within a range?

23
Q

sql

The NOT NULL constraint enforces a column to not accept NULL values.

A

False

NOT NULL prevents NULL values from being accepted

24
Q

sql

Which operator is used to search for a specified pattern in a column?

25
# sql Which SQL statement is used to create a database table called 'Customers'?
CREATE TABLE Customers
26
# sql %
Represents zero or more characters
27
# sql _ (underscore)
Represents a single character
28
# sql []
Represents any single character within the brackets *
29
# slq `^`
Represents any character not in the brackets *
30
# sql -
Represents any single character within the specified range *
31
# sql {}
Represents any escaped character **
32
# sql SELECT
extracts data from a database
33
# sql UPDATE
updates data in a database
34
# sql DELETE
deletes data from a database
35
# sql INSERT INTO
inserts new data into a database
36
# sql CREATE DATABASE
creates a new database
37
# sql ALTER DATABASE
modifies a database
38
# sql CREATE TABLE
creates a new table
39
# sql ALTER TABLE
modifies a table
40
# sql DROP TABLE
deletes a table
41
# sql CREATE INDEX
creates an index
42
# sql DROP INDEX
deletes an index
43
# sql `SELECT * FROM Customers WHERE CustomerName LIKE '%es';`
Return all customers that ends with the pattern 'es'
44
# sql `SELECT * FROM Customers WHERE CustomerName LIKE '%mer%';` | What does this sql block return?
Return all customers that contains the pattern 'mer'
45
# sql `SELECT * FROM Customers WHERE City LIKE '_ondon';` | What does this sql block return?
Return all customers with a City starting with any character, followed by "ondon"
46
# sql `SELECT * FROM Customers WHERE City LIKE 'L_ _ _on';` | What does this sql block return?
Return all customers with a City starting with "L", followed by any 3 characters, ending with "on"
47
# sql `SELECT * FROM Customers WHERE CustomerName LIKE '[bsp]%';` | What does this sql block return?
Return all customers starting with either "b", "s", or "p"
48
# sql `SELECT * FROM Customers WHERE CustomerName LIKE '[a-f]%';` | What does this sql block return?
Return all customers starting with "a", "b", "c", "d", "e" or "f"