CJCoding With Joseph
15free / daySign inCreate account

Add a Column With a Default

Track how many credits each student has earned so far. Add a column credits_earned of type INTEGER with DEFAULT 0 to students. Existing rows get 0 straight away, and any future INSERT that leaves the column out also gets 0.

Expected result:

Table students
✓ id INTEGER PRIMARY KEY
✓ first_name TEXT NOT NULL
✓ last_name TEXT NOT NULL
✓ email TEXT NOT NULL
✓ major_department_id INTEGER
✓ enrollment_year INTEGER NOT NULL
✓ gpa REAL
✓ city TEXT
✓ birth_date TEXT
✓ status TEXT NOT NULL DEFAULT 'active'
✓ scholarship_amount REAL
✓ credits_earned INTEGER DEFAULT 0
✓ major_department_id REFERENCES departments(id)
✓ UNIQUE (email)
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.