W3Schools SQL Insert Into Tutorial A Complete Guide To Inserting Data

Logan Jul 13, 2026

Ever found yourself in a position where you needed to add new data to an existing SQL database? The INSERT INTO statement is exactly what you're looking for. W3Schools offers a wealth of resources to help you understand and apply this crucial SQL operation. Let's dive in and learn how to effectively use the SQL INSERT INTO statement with the help of W3Schools.

a sheet of paper that has some notes on it with words and symbols in the middle
a sheet of paper that has some notes on it with words and symbols in the middle

The SQL INSERT INTO statement is a fundamental command used to add new data to a table in an SQL database. It's an essential skill to master for any SQL user. W3Schools provides clear, step-by-step tutorials and interactive examples to help you grasp this concept swiftly.

SQL Basics Cheat Sheet for Beginners | Learn SQL Fast πŸ’»
SQL Basics Cheat Sheet for Beginners | Learn SQL Fast πŸ’»

Understanding the SQL INSERT INTO Syntax

The basic syntax of the SQL INSERT INTO statement is straightforward. It consists of the following parts:

SQL in 60 days
SQL in 60 days

`INSERT INTO table_name (column1, column2, ..., columnN) VALUES (value1, value2, ..., valueN);`

Let's break down this syntax with the help of a simple example from W3Schools.

SQL Basics Tutorial for Beginners – Structured Query Language Commands, Syntax & Examples Guide
SQL Basics Tutorial for Beginners – Structured Query Language Commands, Syntax & Examples Guide

Inserting Values with Column Names

You can insert values into specific columns by listing the column names in the parentheses, followed by the corresponding values. Here's a basic example from W3Schools' SQL INSERT INTO tutorial:

```sql INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway'); ```

an image of a computer screen with the text,'select from users where user = or
an image of a computer screen with the text,'select from users where user = or

In this example, we're inserting a new customer into the 'Customers' table, specifying the values for each column.

Inserting Values Without Column Names

If you want to insert values into all the columns of a table, you can omit listing the column names and simply use the VALUES keyword. Here's an example from W3Schools:

SQL Joins Explained with Examples | Complete JOIN Cheat Sheet for Beginners
SQL Joins Explained with Examples | Complete JOIN Cheat Sheet for Beginners

```sql INSERT INTO Customers VALUES ('Tipsy', 'Kim A.αΏ€Sun', 'Oceans 10', 'Oslo', '3006', 'Norway'); ```

This will insert a new customer into the 'Customers' table, filling all columns with the provided values.

Sql Cheat Sheet, Learn Sql, Learn Web Development, Excel Tutorials, Sql Server, Career Options, Data Analyst, Data Scientist, Data Analysis
Sql Cheat Sheet, Learn Sql, Learn Web Development, Excel Tutorials, Sql Server, Career Options, Data Analyst, Data Scientist, Data Analysis
SQL Cheat Sheet in 60 seconds πŸ‘‡
SQL Cheat Sheet in 60 seconds πŸ‘‡
SQL Sheatsheet! πŸ‘
SQL Sheatsheet! πŸ‘
Learn SQL just by investing 30 minutes a day within 30 Days
Learn SQL just by investing 30 minutes a day within 30 Days
SQL Joins Cheat Sheet Every Developer Should Save
SQL Joins Cheat Sheet Every Developer Should Save
SQL CASE WHEN Explained with Examples | Beginner SQL Tutorial
SQL CASE WHEN Explained with Examples | Beginner SQL Tutorial
SQl quick 1 min cheat sheet
SQl quick 1 min cheat sheet
SQL Cheatsheet In 2026 πŸš€
SQL Cheatsheet In 2026 πŸš€
SQL
SQL
SQL Cheatsheet β€” Learn the Basics Fast New to databases? Here’s a quick SQL cheatsheet with the most-used commands: SELECT, INSERT, UPDATE, DELETE, and more. Perfect for beginners and a great refresh for pros! #SQLCheatsheet #LearnSQL #DatabaseBasics #SQLCommands #CodingForBeginners #BackendTips #DevTools #TechCheatsheet #QueryLikeAPro #SQLTips #savageslayer #programbereach #sohaibalikhan #sohaibbashirkhan #researchteq #savageslayerofficials #datawarlord #datawarlordofficial #wordpressdevelop... Sql Cheat Sheet, Learn Sql, Sql Commands, Coding For Beginners, Wordpress Developer, Study Inspiration, Cheat Sheets, Web Development, The Selection
SQL Cheatsheet β€” Learn the Basics Fast New to databases? Here’s a quick SQL cheatsheet with the most-used commands: SELECT, INSERT, UPDATE, DELETE, and more. Perfect for beginners and a great refresh for pros! #SQLCheatsheet #LearnSQL #DatabaseBasics #SQLCommands #CodingForBeginners #BackendTips #DevTools #TechCheatsheet #QueryLikeAPro #SQLTips #savageslayer #programbereach #sohaibalikhan #sohaibbashirkhan #researchteq #savageslayerofficials #datawarlord #datawarlordofficial #wordpressdevelop... Sql Cheat Sheet, Learn Sql, Sql Commands, Coding For Beginners, Wordpress Developer, Study Inspiration, Cheat Sheets, Web Development, The Selection
SQL developer Hand written Notes (Page-1)
SQL developer Hand written Notes (Page-1)
SQL JOINS Made Easy πŸ”— | INNER, LEFT, RIGHT & FULL JOIN with Examples
SQL JOINS Made Easy πŸ”— | INNER, LEFT, RIGHT & FULL JOIN with Examples
Save This SQL Commands Cheat Sheet Before Your DBMS Exam! πŸ’»πŸ“š
Save This SQL Commands Cheat Sheet Before Your DBMS Exam! πŸ’»πŸ“š
Basics Of MySQL πŸ’»
Basics Of MySQL πŸ’»
πŸ’» SQL Basics Made Simple | Beginner-Friendly DBMS Notes
πŸ’» SQL Basics Made Simple | Beginner-Friendly DBMS Notes
7 SQL Commands Every Beginner Must Know
7 SQL Commands Every Beginner Must Know
SQL Cheatsheet PDF | SQL Commands, Joins & Queries Explained
SQL Cheatsheet PDF | SQL Commands, Joins & Queries Explained
a poster with the names and symbols for different types of letters
a poster with the names and symbols for different types of letters
SQL Cheat Sheet for Beginners | Essential Commands & Queries
SQL Cheat Sheet for Beginners | Essential Commands & Queries
SQL JOIN Cheat Sheet for Beginners | INNER JOIN vs LEFT JOIN vs RIGHT JOIN vs FULL JOIN
SQL JOIN Cheat Sheet for Beginners | INNER JOIN vs LEFT JOIN vs RIGHT JOIN vs FULL JOIN

Inserting a Unknown Number of Rows

What if you have to insert a large number of rows? You can use the SELECT command in conjunction with the INSERT INTO statement to avoid typing all the values manually. Let's explore this with an example from W3Schools.

Using the SELECT Command

The SQL SELECT command can be used to select data from one or more tables and insert it into another table. Here's an example of how to use it with INSERT INTO:

```sql INSERT INTO Customers_2020 (CustomerName, ContactName, Address, City, PostalCode, Country) SELECT CustomerName, ContactName, Address, City, PostalCode, Country FROM Customers; ```

In this case, we're selecting data from the 'Customers' table and inserting it into the 'Customers_2020' table.

Using the SELECT DISTINCT Command

If you want to insert only unique values, you can use the SELECT DISTINCT command. This is particularly useful when you have duplicate rows in one table, and you want to insert only the unique values into another table. Here's an example from W3Schools:

```sql INSERT INTO Countries (CountryID, CountryName) SELECT DISTINCT Country FROM Customers; ```

This will insert all unique country names from the 'Customers' table into the 'Countries' table.

With this newfound knowledge, you're ready to start adding new data to your SQL databases like a pro! Don't forget to explore more SQL tutorials at W3Schools to continue mastering this essential skill. Happy coding!