SQL INSERT INTO

SQL Tutorial

 SQL INSERT INTO Statement (Beginner → Advanced)

The INSERT INTO statement in SQL is used to add new records (rows) into a table.
It is one of the most frequently used SQL commands and is very important for interviews and real projects.


 What is INSERT INTO?

INSERT INTO is used to insert new data into a table.


 

or


 


 Insert Values into All Columns

Table: students


 

How to Insert Data in SQL


 

  •  Order of values must match column order
  • Warning: Not recommended if table structure changes

Adding Data into Specific Columns (Recommended)


 

  • marks will be NULL or DEFAULT
  •  Safer and clearer

Ways to Insert Multiple Rows at Once


 

  •  Faster than multiple INSERT statements
  •  Very common in real projects

Using DEFAULT Values While Inserting Data


 

  • Uses column’s default value

Storing NULL Values in SQL Tables


 

  •  Allowed only if column is not NOT NULL

Copying Data from Another Table in SQL


 

  •  Inserts result of a SELECT query
  •  Used in data migration & reporting

Adding Current Date and Time Automatically


 

  •  Automatically stores current date & time

Using a Subquery to Insert Records


 

  •  Advanced but very useful

INSERT INTO vs UPDATE

FeatureINSERTUPDATE
Adds new row Yes No
Modifies existing row NoYes
Uses WHERE NoYes

 Common Mistakes

  •  Column count ≠ value count
  •  Wrong data type
  •  Missing quotes for strings
  •  Inserting NULL into NOT NULL column
  •  Forgetting column list

 Interview Questions (Must Prepare)

  1. What is INSERT INTO used for?

  2. Difference between inserting all columns vs specific columns?

  3. How to insert multiple rows?

  4. Can we insert data using SELECT?

  5. What happens if column allows NULL?

  6. Difference between INSERT and UPDATE?


Real-Life Use Cases

  • User registration

  • Order creation

  • Logging events

  • Data migration

  • Importing CSV data


 Summary

  • INSERT INTO adds new records to a table
  •  Can insert single or multiple rows
  •  Supports DEFAULT, NULL, and subqueries
  •  Safer to specify column names
  •  Core command for database operations & interviews

You may also like...