SQL LaunchPad

SQL Data Addition Tool : INSERT

Learning Outcome

5

Relate DML and INSERT operations with Instagram real-life examples

4

Insert data into tables using SQL

3

Explain the purpose of INSERT command

2

Differentiate between DDL and DML

1

Understand what DML (Data Manipulation Language) is

Recall

DDL commands create and modify table structure

Tables like Users, Posts, Likes already exist

DDL defines what columns are there

But no actual Instagram users or posts exist yet

Hook/Story/Analogy(Slide 4)

Transition from Analogy to Technical Concept(Slide 5)

What is DML?

Data Manipulation Language is used to manage and modify data inside tables in a database.

DML works on rows (records), not structure.

DML commands are used to:

Insert data

Modify data

Delete data

Common DML Commands:

INSERT

UPDATE

DELETE

SELECT (often categorized separately)

INSERT Command

INSERT Command is used to add new data (records/rows) into a table.

Basic INSERT Syntax

INSERT INTO table_name
VALUES (value1, value2, value3);

Adds full row

Values must match column order

Imagine a table called InstagramUsers

INSERT INTO InstagramUsers
VALUES (1, 'Siya', 'Siya@gmail.com', 1200);

Insert value

INSERT with Column Names

Why use column names?

INSERT with column names is a way to add data into a table by specifying the columns where the values will go.

  • Better readability

  • Order does not matter
  • Safe insertion

Syntax

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

Imagine a table called InstagramUsers

INSERT INTO InstagramUsers (user_id, username, email, followers)

VALUES (1, 'Siya', 'Siya@gmail.com', 1200); 

Insert value with Column name

 INSERT with Column Names 

 INSERT with Column Names 

INSERT Multiple Rows

INSERT Multiple Rows allows inserting multiple records into a table in a single query.

Syntax

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

 

Why Use INSERT Multiple Rows?

  • Saves Time
  • Better Performance
  • Used in Bulk Data Insertion

Imagine a table called InstagramUsers

Insert value with Multiple Rows

INSERT INTO InstagramUsers(user_id, username, email, followers)

VALUES (2, 'Ram', 'ram@gmail.com', 1500),

(3, 'Geeta', 'geeta@gmail.com', 1000);

Summary

5

Without DML, tables remain empty

4

Instagram users and posts exist because of INSERT

3

Works on rows, not structure

2

INSERT command adds new records

1

DML is used to manipulate data

Quiz

What is the main purpose of DML commands in SQL?

A. To create database structure

B. To manipulate data inside tables

C. To control user access

D. To define relationships

Quiz-Answer

What is the main purpose of DML commands in SQL?

A. To create database structure

B. To manipulate data inside tables

C. To control user access

D. To define relationships

Copy of OG Template

By Content ITV

Copy of OG Template

  • 8