SQL INSERT INTO

Add new rows.

✍️ 3 exercises + code challenge in this lesson

INSERT INTO adds new records to a table.

  • Name the columns, then give values in the same order:
    INSERT INTO Customers (CustomerName, City, Country) VALUES ('New Shop', 'Multan', 'Pakistan');
  • Columns you leave out get NULL or their default value.
  • Insert several rows at once by separating value lists with commas.
The sample database is rebuilt on every run, so your changes are never permanent here. Experiment freely!

Key Takeaways: SQL INSERT INTO

Mastering SQL INSERT INTO helps you write clean and reliable SQL code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

SQL INSERT INTO Code Example

SQL
INSERT INTO Customers (CustomerName, ContactName, City, Country)
VALUES ('Multan Mobiles', 'Zain Ali', 'Multan', 'Pakistan'),
       ('Quetta Carpets', 'Gul Khan', 'Quetta', 'Pakistan');

SELECT * FROM Customers ORDER BY CustomerID DESC LIMIT 3;
Free sign-in required · Google login available

SQL INSERT INTO Practice Exercises

Check what you learned in “SQL INSERT INTO”.

/ 3 solved
Fill in the blank

Insert a new row.

 Customers (CustomerName, City) VALUES ('New Shop', 'Multan');
✓ Correct! Not quite. Try again.
Multiple choice

What value does a column you leave out of INSERT get?

✓ Correct! Not quite. Try again.
Code challenge

Insert a product 'Webcam' in 'Electronics' with price 6000 and stock 15, then select ProductName, Price for products whose name is 'Webcam'.

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services