Adding Rows with SQL INSERT
INSERT adds new rows. Name the columns, supply matching values, then SELECT to confirm.
INSERT
adds new rows. List the columns you're filling, then provide a value for
each in the same order. Naming the columns explicitly instead of relying on
table order keeps the statement readable and resilient.
Then do what every careful person does after a change: SELECT the row back to confirm it's really there. This exercise runs against a fresh copy each time you click Run, so you can insert as many times as you like.
insert into customers (customer_id, first_name, last_name)
values (21, 'Robin', 'Vale');
select * from customers where customer_id = 21; Schema · Garden Shop Table · products 9 columns · 24 rows
One row per product, with price, cost, and inventory levels.
Add a new product, then confirm it. Insert a row into
products with product_id 25, name
'Window Herb Kit', category 2, supplier 6, price 24.00,
cost 11.00, 30 on hand, reorder level 10, and not discontinued. Then
SELECT product_id, product_name, and price
for product 25.
Run your query to inspect the result.
Expected answer
- Columns: product_id, product_name, price.
- Rows: 1, the product you just inserted.
- product_id 25 is 'Window Herb Kit' at price 24.
Related
A checklist for changing the right rows.
ROW_NUMBER() needs an ORDER BY that says which row wins.
ON CONFLICT, INSERT OR REPLACE, and MERGE.
Store a query result as a table you can query again.
Understand INSERT, UPDATE, and DELETE.
Change existing rows safely.