← Back to CREATE TABLE
Question 91
Rules the Database Enforces
Rules the Database Enforces
CreateclubswithidINTEGER PRIMARY KEY;nameTEXT NOT NULL UNIQUE;founded_yearINTEGERwith aCHECKthat it is at least 1900 (NULL is allowed, so a club with an unknown founding year passes); andmember_capINTEGER NOT NULL DEFAULT 30with aCHECKthat it is greater than 0. Write each CHECK on its own column: a club founded in 1800 and a club with a cap of 0 must both be refused, and two clubs named 'Chess' cannot coexist.
Expected result:
Table clubs ✓ id INTEGER PRIMARY KEY ✓ name TEXT NOT NULL ✓ founded_year INTEGER ✓ member_cap INTEGER NOT NULL DEFAULT 30 ✓ UNIQUE (name) ✓ A club founded in 1800: rejected (CHECK) ✓ A club founded in 1999: accepted ✓ A club that may have 0 members: rejected (CHECK) ✓ Two clubs both called Chess: rejected (UNIQUE) ✓ A club whose founding year 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.