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

Arrastra en el orden correspondiente.


Arrastra las opciones:

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

Completa el código:

______
______
______
______
______

Interactive Quiz 2: Fill in the Blanks

Rellena los huecos en cada casilla.


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
1Juan25
2Ana30
3Luis22
4Marta35
5Juan27
6Ana30

* Escribe tu consulta SQL y ejecuta para ver los resultados.



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