Grokking SQL for Tech Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
INSERT
On this page

DML

INSERT

Example

DML

DML stands for Data Manipulation Language, and it is a subset of SQL (Structured Query Language) used for managing and manipulating data within a relational database management system (RDBMS).

DML is responsible for performing operations on data, such as inserting, updating, and deleting records in a database. The following are the main types of DML operations:

INSERT

The INSERT statement in SQL adds new records to a table. It allows you to specify the values for each column or insert data into the table.

INSERT INTO table_name (column1, column2) VALUES (value1, value2);

Let's break down the components of the INSERT statement:

  • INSERT INTO table_name: This part indicates the table where you want to insert the data.
  • (column1, column2, column3, ...): This part is optional if you are not inserting values into all columns.
  • VALUES (value1, value2, value3, ...): This part specifies the values you want to insert into the corresponding columns.

Example

Suppose we have an employees table as shown below.

Image

To add a new record to the employees table, we will write the following query:

INSERT INTO employees VALUES ("Monica", "Geller", 28);

After executing the INSERT query the employees table will look like this

Image

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page

DML

INSERT

Example