← Back to Constraints
Question 69
Workshop Credits Between 1 and 4
Workshop Credits Between 1 and 4
Create a table calledworkshopswith three columns:id(anINTEGER PRIMARY KEY),title(TEXT, required) andcredits(INTEGER, required). Credits must fall in the range 1 to 4 inclusive: a workshop worth 0 or 5 credits must be rejected, while 1 and 4 are fine. Write the range rule as aCHECKon thecreditscolumn.
Expected result:
Table workshops ✓ id INTEGER PRIMARY KEY ✓ title TEXT NOT NULL ✓ credits INTEGER NOT NULL ✓ Insert a workshop worth 5 credits: rejected (CHECK) ✓ Insert a workshop worth 0 credits: rejected (CHECK) ✓ Insert a workshop worth 4 credits: accepted ✓ Insert a workshop with no credits at all: rejected (NOT NULL)
Hints3 available
Sign in to use hintsTopics:
Constraints
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sel, ins, desc)
Results
Run your SQL to see every statement's output here, then how it compares with the expected answer.
Not sure what is in a table? SHOW TABLES lists them and DESCRIBE students shows the columns — or open the database browser on the left.