easy +10 pts

Add column alter

Use ALTER TABLE to add a new column to an in-memory SQLite database.

Implement a function `add_column_alter()` that performs the following steps using Python's built-in `sqlite3` module. No external packages are allowed. 1. Connect to an in-memory SQLite database. 2. Create a table named `employees` with columns: `id INTEGER PRIMARY KEY`, `name TEXT NOT NULL`, `salary REAL NOT NULL`. 3. Insert exactly these three rows: - (1, 'Alice', 75000) - (2, 'Bob', 68000) - (3, 'Carol', 82000) 4. Add a new column `department TEXT` to the `employees` table using an `ALTER TABLE` statement. 5. Update the department for each employee: Alice -> 'Engineering', Bob -> 'Sales', Carol -> 'Engineering'. 6. Close the connection. 7. Return a list of lists representing the full table rows after the update, ordered by `id`. Your function should return a list of lists in the format `[id, name, salary, department]`, for example: `[[1, 'Alice', 75000, 'Engineering'], ...]`.

Constraints

- The function takes no arguments. - The returned list must contain exactly 3 lists. - Each inner list must be `[int, str, float, str]`. - The order must be by `id` ascending. - Use only the `sqlite3` module from the standard library.

Example

>>> add_column_alter()
[[1, 'Alice', 75000.0, 'Engineering'], [2, 'Bob', 68000.0, 'Sales'], [3, 'Carol', 82000.0, 'Engineering']]
10 points ~15 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Use `:memory:` as the database path to create an in-memory SQLite database.
Store the connection in a variable and use `cursor()` to execute SQL statements.
After ALTER TABLE, run an UPDATE statement for each employee or use a single UPDATE with CASE.
Convert each returned tuple to a list before building the final result.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.