CodeBlanks Logo Icon CodeBlanks

Product table

Write queries to list and filter products.

Adding items

To add items to the inventory you use INSERT. You enter name, quantity and location info.

INSERT INTO inventory (id, name, qty, location)
VALUES (1, 'Vidalı', 100, 'A1');

This query adds 100 screws to shelf A1.

The values given with VALUES are inserted into inventory as new rows.

Adding items — details

Each inventory line is a row. Location info helps find the product on the shelf quickly.

Practice Adding items

Insert id=2, name='Bolt', qty=50, location='B2' into inventory.

Starter code

query.sql
-- add to inventory
INSERT INTO inventory
VALUES

Sample solution

query.sql
INSERT INTO inventory (id, name, qty, location)
VALUES (2, 'Civata', 50, 'B2')

Expected output

1 satır eklendi

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Values

Question
INSERT INTO inventory (id, name, qty)
____ (2, 'Civata', 50);
Answer
INSERT INTO inventory (id, name, qty)
VALUES (2, 'Civata', 50);

Explanation: The values of the new product row are given with VALUES.

2 Which statement adds an item to inventory?

  • DELETE
  • ALTER
  • INSERT Correct answer
  • DROP

Explanation: INSERT adds a new row.

3 Product table: match the terms

Term Meaning
INSERT insert
INTO into
VALUES values
SELECT read

All lessons in Beginner