ISDD - SQL Flashcards

1
Q

How would you create a table in SQL?

A

CREATE TABLE aa characters (id INTEGER PRIMARY KEY, forename STRING, surname STRING, age_(during SoJ) INTEGER, job STRING);

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

How do you insert a record into a table using SQL?

A

INSERT INTO aa characters

VALUES (1, “Phoenix”, “Wright”, 35, “Defense Attorney”);

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

How do you delete a record from a table using SQL?

A

DELETE FROM aa characters

WHERE forename = “Matt” AND surname = “Engarde”;

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

How do you update a table in SQL?

A

UPDATE aa characters
SET age = 27
WHERE forename = “Ema” AND surname = “Skye”;

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

What is the algorithm for running a query, say on defence attorneys using SQL?

A

SELECT * FROM aa characters

WHERE job = “Defense Attorney”;

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

How do you display a table and all of its contents using SQL?

A

SELECT * FROM aa characters;

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

How would you order a queries results using SQL?

A

ORDER BY age [ASC/DESC];

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

How would you use a COUNT function to find out how many of each thing you have in a query using SQL?

A

SELECT job, COUNT(job) AS number
FROM aa characters
GROUP BY job;

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

How would you rename a field in a query in SQL?

A

… job AS occupation …;

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