SQL practice: Tables, Types and Constraints
Chapter 29 · 8 questions · included in full access
Question 1 · easy
Solve it in your browserWrite the statement adding a CHECK that order_items.quantity must be above 0.
Question 2 · easy
Solve it in your browserWrite the statement adding an email column to customers.
Question 3 · medium
Solve it in your browserCreate a table suppliers with an auto ID, a name that can't be blank, a city, and a rating between 0 and 5.
Question 4 · medium
Solve it in your browserAdd a DEFAULT of 'Pending' to orders.status. (Write the ALTER.)
Question 5 · medium
Solve it in your browserWhich type would you choose for: a phone number, an invoice total, a delivery date, a "is active" flag? Justify the phone number one.
Question 6 · medium
Solve it in your browserWrite a CHECK making sure products.unit_price is never below cost_price.
Question 7 · hard
Solve it in your browserExplain what would go wrong if orders.customer_id had no foreign key constraint.
Question 8 · hard
Solve it in your browserCreate a temporary table named temp_lead_stage with two columns: lead_id (INT) and lead_score (NUMERIC(5,2)).
These questions are part of full access.
The first chapters of every track are free. Full access is a one-time payment.
See pricing