← Back to CREATE TABLE
Question 88
No Two Rooms Share a Code
No Two Rooms Share a Code
CreateroomswithidINTEGER PRIMARY KEY,codeTEXT NOT NULL UNIQUEandcapacityINTEGER(NULL allowed). Inserting two rooms with the same code must fail, a room with no code must fail, and a room with a code but no capacity must be accepted.
Expected result:
Table rooms ✓ id INTEGER PRIMARY KEY ✓ code TEXT NOT NULL ✓ capacity INTEGER ✓ UNIQUE (code) ✓ Two rooms both coded T-100: rejected (UNIQUE) ✓ A room with no code: rejected (NOT NULL) ✓ A room whose capacity is unknown: accepted
Hints3 available
Sign in to use hintsTopics:
CREATE TABLE
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.