ISDD - SQL Flashcards
How would you create a table in SQL?
CREATE TABLE aa characters (id INTEGER PRIMARY KEY, forename STRING, surname STRING, age_(during SoJ) INTEGER, job STRING);
How do you insert a record into a table using SQL?
INSERT INTO aa characters
VALUES (1, “Phoenix”, “Wright”, 35, “Defense Attorney”);
How do you delete a record from a table using SQL?
DELETE FROM aa characters
WHERE forename = “Matt” AND surname = “Engarde”;
How do you update a table in SQL?
UPDATE aa characters
SET age = 27
WHERE forename = “Ema” AND surname = “Skye”;
What is the algorithm for running a query, say on defence attorneys using SQL?
SELECT * FROM aa characters
WHERE job = “Defense Attorney”;
How do you display a table and all of its contents using SQL?
SELECT * FROM aa characters;
How would you order a queries results using SQL?
…
ORDER BY age [ASC/DESC];
How would you use a COUNT function to find out how many of each thing you have in a query using SQL?
SELECT job, COUNT(job) AS number
FROM aa characters
GROUP BY job;
How would you rename a field in a query in SQL?
… job AS occupation …;