Move beyond reading data to changing it. This SQLite-focused lesson covers inserting new rows, updating existing records, deleting safely, understanding SQLite's flexible type system, and working with ISO 8601 dates.
Add a new product to the database. INSERT INTO is how new data enters your tables ā every signup form, order placement, and data import uses INSERT behind the scenes.
sqlite3 ecommerce.db.headers on.mode columnINSERT INTO products (name, description, price, category_id, stock_quantity, is_available) VALUES ('Wireless Earbuds Pro', 'Premium noise-cancelling wireless earbuds', 79.99, 1, 150, 1);SELECT * FROM products ORDER BY id DESC LIMIT 3;INSERT INTO has two parts: the column list (which columns you're providing values for) and VALUES (the actual data). Columns you omit will use their default values ā for example, `id` auto-increments and `created_at` defaults to the current timestamp. The column list and values must match in order and count: the first value goes into the first column, the second value into the second column, and so on.
The INSERT completes silently (no output means success in SQLite). The SELECT query confirms your new product appears as the last row, with an auto-generated id and created_at timestamp.