Hint: CREATE TABLE is the right start for making tables [OK]
Common Mistakes:
Using MAKE TABLE instead of CREATE TABLE
Wrong order of keywords
Using STRING instead of TEXT for text columns
3. Given the table feedback with columns id and comment, what will this query return?
SELECT comment FROM feedback WHERE id = 2;
medium
A. Only the comment text where id equals 2
B. An error because id is not selected
C. All ids and comments
D. All comments with id 2
Solution
Step 1: Understand the SELECT statement
The query asks for the comment column only, filtering rows where id equals 2.
Step 2: Determine what is returned
Only the comment text for the row with id 2 is returned, not all comments or ids.
Final Answer:
Only the comment text where id equals 2 -> Option A
Quick Check:
SELECT comment WHERE id=2 = Only the comment text where id equals 2 [OK]
Hint: SELECT column filters output columns, WHERE filters rows [OK]
Common Mistakes:
Thinking all comments with id 2 means multiple rows
Expecting id column in output when not selected
Assuming syntax error due to missing id in SELECT
4. Identify the error in this SQL statement for inserting feedback:
INSERT INTO feedback (id, comment) VALUES 1, 'Great service';
medium
A. Missing parentheses around VALUES
B. Wrong table name
C. Missing semicolon
D. Using single quotes instead of double quotes
Solution
Step 1: Review correct INSERT syntax
VALUES must be followed by parentheses enclosing the values to insert.
Step 2: Check the given statement
The statement lacks parentheses around 1, 'Great service' after VALUES.
Final Answer:
Missing parentheses around VALUES -> Option A
Quick Check:
VALUES requires parentheses [OK]
Hint: Always put parentheses around VALUES in INSERT [OK]
Common Mistakes:
Forgetting parentheses after VALUES
Confusing quotes for strings
Assuming semicolon is mandatory for error
5. You want to label feedback comments as 'positive' or 'negative' in a new column annotation. Which SQL command correctly adds this column to the feedback table?
hard
A. INSERT COLUMN annotation INTO feedback;
B. UPDATE feedback ADD annotation TEXT;
C. CREATE COLUMN annotation TEXT IN feedback;
D. ALTER TABLE feedback ADD COLUMN annotation TEXT;
Solution
Step 1: Understand how to add a new column
To add a column, use ALTER TABLE with ADD COLUMN and specify the type.
Step 2: Check each option's correctness
ALTER TABLE feedback ADD COLUMN annotation TEXT; uses correct syntax. Others use invalid commands or order.
Final Answer:
ALTER TABLE feedback ADD COLUMN annotation TEXT; -> Option D
Quick Check:
ALTER TABLE + ADD COLUMN = ALTER TABLE feedback ADD COLUMN annotation TEXT; [OK]
Hint: Use ALTER TABLE ADD COLUMN to add new columns [OK]