W3 SQL Flashcards

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?

A

INNER JOIN

22
Q

sql

Which operator is used to select values within a range?

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?

A

LIKE

25
Q

sql

Which SQL statement is used to create a database table called ‘Customers’?

A

CREATE TABLE Customers

26
Q

sql

%

A

Represents zero or more characters

27
Q

sql

_ (underscore)

A

Represents a single character

28
Q

sql

[]

A

Represents any single character within the brackets *

29
Q

slq

^

A

Represents any character not in the brackets *

30
Q

sql

-

A

Represents any single character within the specified range *

31
Q

sql

{}

A

Represents any escaped character **

32
Q

sql

SELECT

A

extracts data from a database

33
Q

sql

UPDATE

A

updates data in a database

34
Q

sql

DELETE

A

deletes data from a database

35
Q

sql

INSERT INTO

A

inserts new data into a database

36
Q

sql

CREATE DATABASE

A

creates a new database

37
Q

sql

ALTER DATABASE

A

modifies a database

38
Q

sql

CREATE TABLE

A

creates a new table

39
Q

sql

ALTER TABLE

A

modifies a table

40
Q

sql

DROP TABLE

A

deletes a table

41
Q

sql

CREATE INDEX

A

creates an index

42
Q

sql

DROP INDEX

A

deletes an index

43
Q

sql

SELECT * FROM Customers WHERE CustomerName LIKE '%es';

A

Return all customers that ends with the pattern ‘es’

44
Q

sql

SELECT * FROM Customers WHERE CustomerName LIKE '%mer%';

What does this sql block return?

A

Return all customers that contains the pattern ‘mer’

45
Q

sql

SELECT * FROM Customers WHERE City LIKE '_ondon';

What does this sql block return?

A

Return all customers with a City starting with any character, followed by “ondon”

46
Q

sql

SELECT * FROM Customers WHERE City LIKE 'L_ _ _on';

What does this sql block return?

A

Return all customers with a City starting with “L”, followed by any 3 characters, ending with “on”

47
Q

sql

SELECT * FROM Customers WHERE CustomerName LIKE '[bsp]%';

What does this sql block return?

A

Return all customers starting with either “b”, “s”, or “p”

48
Q

sql

SELECT * FROM Customers WHERE CustomerName LIKE '[a-f]%';

What does this sql block return?

A

Return all customers starting with “a”, “b”, “c”, “d”, “e” or “f”