CJCoding With Joseph
15free / daySign inCreate account

Add a Required Column

Courses need a flag saying whether they run online. Add is_online to courses as an INTEGER column that is NOT NULL with DEFAULT 0. SQLite refuses to add a NOT NULL column without a default, because the 14 existing rows would have nothing to put in it, so the default is what makes this possible.

Expected result:

Table courses
✓ id INTEGER PRIMARY KEY
✓ code TEXT NOT NULL
✓ title TEXT NOT NULL
✓ department_id INTEGER NOT NULL
✓ instructor_id INTEGER
✓ credits INTEGER NOT NULL DEFAULT 3
✓ level INTEGER NOT NULL
✓ max_seats INTEGER
✓ room TEXT
✓ semester TEXT
✓ fee REAL
✓ is_online INTEGER NOT NULL DEFAULT 0
✓ instructor_id REFERENCES instructors(id)
✓ department_id REFERENCES departments(id)
✓ UNIQUE (code)
Hints3 available
Topics:
ALTER & DROP
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.