Lessons › SQL › Deep Dive: Database Admin & ETL
SQL lesson
INSERT INTO
INSERT INTO writes brand-new rows into an existing table - instead of reading data, you're adding to it.
Try this lesson free →Example
Adding New Retail Products with INSERT INTO
INSERT INTO products (product_id, product_name, category, price, stock_count)
VALUES ('P2006', 'Yoga Mat', 'Fitness', 39.99, 25)Step by step
- Start with INSERT INTO and the name of the table you want to add rows to.
INSERT INTO products; - Inside parentheses, list the columns you're providing values for, comma-separated.
INSERT INTO products (product_id, product_name, category, price, stock_count); - VALUES followed by a tuple of values - one value per listed column, in the same order.
INSERT INTO products (product_id, product_name, category, price, stock_count) VALUES ('P2006', 'Yoga Mat', 'Fitness', 39.99, 25);
Practice
1. Write an INSERT statement to add a new row to products with values 'P2001', 'NovaTech', 'Electronics' for columns product_id, brand, category.
INSERT INTO products (product_id, brand, category) VALUES ('P2001', 'NovaTech', 'Electronics')2. Write an INSERT statement to add a new row to customers with values 'C101', 'Alice Chen', 'alice.chen@shopmail.com' for columns customer_id, full_name, email.
INSERT INTO customers (customer_id, full_name, email) VALUES ('C101', 'Alice Chen', 'alice.chen@shopmail.com')3. Write an INSERT statement to add a new row to orders with values 'O2001', 'C101', 'Electronics' for columns order_id, customer_id, category.
INSERT INTO orders (order_id, customer_id, category) VALUES ('O2001', 'C101', 'Electronics')4. Write an INSERT statement to add a new row to inventory with values 'P2001', 'East', 120 for columns product_id, warehouse, stock_count.
INSERT INTO inventory (product_id, warehouse, stock_count) VALUES ('P2001', 'East', 120)5. Write an INSERT statement to add a new row to suppliers with values 'SUP001', 'Nordic Electronics', 'Norway' for columns supplier_id, supplier_name, country.
INSERT INTO suppliers (supplier_id, supplier_name, country) VALUES ('SUP001', 'Nordic Electronics', 'Norway')Learn it by doing. This lesson is a short hands-on level on Bampaa: see it work, then build and write it yourself, with instant feedback.
Try this lesson free →