Inserting Data with INSERT INTO


  The INSERT INTO command in SQL allows you to add new records to a table. It's essential for storing new data in a structured manner.


Syntax


The basic syntax for inserting data into an SQL table is:
INSERT INTO [table] (column1, column2, ...) VALUES (value1, value2, ...);
You can omit the columns if you're inserting into all columns of the table.


Purpose


INSERT INTO is fundamental for adding data to tables. For example, it allows you to:


  • Add new products to an online store.
  • Register users in an application.
  • Add sales records to an inventory system.


Exercises



Interactive Quiz 1: Drag and Drop

Drag in the corresponding order.


Drag the options:

INSERT
INTO
products
VALUES
(1, 'Product X', 20)

Completa el código:

______
______
______
______
______

Interactive Quiz 2: Fill in the Blanks

Fill the Blanks.


INSERT INTO products (id, name, price) VALUES (, '', );

Practical Exercise:

Statement:

  Write an SQL query to insert a new product with a price of 100.

Datos de Ejemplo

idnameage
1John25
2Anna30
3Kevin22
4Angela35
5John27
6Anna30

* Write your SQL query and execute to see results.



Which of the following commands is used to insert data in SQL?