Test 2 - Teachers
Test 2 - Teachers
Fundamentals
Name: ___________________________
Student ID: _____________________
Date: ___________________________
4. To view all columns in a table named employees, the correct query begins with
_________.
Keyword Description
1. Write a query to create a table named students with columns id (integer, primary
key), name (varchar), and birthdate (date).
2. Write a query to retrieve all rows from the students table where birthdate is after
2004-01-01.
4. Write a query to count the total number of students in the students table.
5. Write a query to sort the students table by name in descending order.
2. Write a query to create a trigger that logs an entry in the log_table whenever a row in
the students table is deleted.
3. Write a query using the CASE statement to categorize employees earning above 50000
as High Income and others as Low Income.
5. What does the BETWEEN keyword achieve in a query, and why might you use it?
3. Write a query to find the highest salary from the employees table.
4. Write a query to create a new table departments with columns dept_id (integer,
primary key) and dept_name (unique, varchar).
Solutions
Part I: Fill-in-the-Blanks
1. CREATE
2. DROP
3. INSERT
4. SELECT * FROM employees
5. ALTER
Part II: Match the Columns
A→2
B→1
C→3
D→4
4. BETWEEN specifies a range, e.g., BETWEEN 100 AND 200 finds values in this range.
);