Add a CHECK constraint for rating
SQL
Easy
9 views
Problem Description
In table Reviews(review_id, rating, comment), rating must be between 1 and 5.
Output Format
DDL statement(s)
Sample Test Case
Input:
Reviews(review_id, rating, comment)
Constraints
Assume table exists
Official Solution
ALTER TABLE Reviews ADD CONSTRAINT chk_rating CHECK (rating BETWEEN 1 AND 5);
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!