🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to SQL Notes
Topic #11

SQL Insert Into


The SQL INSERT INTO Statement

The INSERT INTO statement is used to insert new records in a table.

It is possible to write the INSERT INTO statement in two ways:

Syntax 1

Specify both the column names and the values to be inserted:

<p><code class="sqlHigh">
INSERT INTO <em>table_name</em> (<em>column1</em>,<em> column2</em>,<em> column3</em>, ...)<br/>
VALUES (<em>value1</em>,<em> value2</em>,<em> value3</em>, ...);</code></p>

Syntax 2

If you insert values for ALL the columns of the table, you can omit the column names.

However, the order of the values must be in the same order as the columns in the table:

<p><code class="sqlHigh">
INSERT INTO <em>table_name</em><br/>
VALUES (<em>value1</em>,<em> value2</em>,<em> value3</em>, ...);</code></p>

Demo Database

Below is a selection from the Customers table used in the examples:

CustomerID CustomerName ContactName Address City PostalCode Country
89 White Clover Markets Karl Jablonski 305 - 14th Ave. S. Suite 3B Seattle 98128 USA
90 Wilman Kala Matti Karttunen Keskuskatu 45 Helsinki 21240 Finland
91 Wolski Zbyszek ul. Filtrowa 68 Walla 01-012 Poland

INSERT INTO Example

Here we insert values for ALL the columns of the table, so we omit the column names.

The following SQL inserts a new record in the "Customers" table:

Example

INSERT INTO Customers

VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway');

The last record in the "Customers" table will now look like this:

CustomerID CustomerName ContactName Address City PostalCode Country
92 Cardinal Tom B. Erichsen Skagen 21 Stavanger 4006 Norway

Note: Notice that we did not insert any number into the CustomerID field! The CustomerID column is an auto-increment field and will be automatically generated when a new record is inserted.


Insert Data Only in Specific Columns

Here we insert values only in some specific columns of the table.

The following SQL inserts a new record - but only inserts data in the "CustomerName", "City", and "Country" columns (CustomerID will be updated automatically):

Example

INSERT INTO Customers (CustomerName, City, Country)

VALUES ('Cardinal', 'Stavanger', 'Norway');

The last record in the "Customers" table will now look like this:

CustomerID CustomerName ContactName Address City PostalCode Country
92 Cardinal null null Stavanger null Norway

Insert Multiple Rows

To insert multiple rows of data, we use the same INSERT INTO statement, but with multiple values:

The following SQL inserts three new records in the "Customers" table:

Example

INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)

VALUES

('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway'),

('Greasy Burger', 'Per Olsen', 'Gateveien 15', 'Sandnes', '4306', 'Norway'),

('Tasty Tee', 'Finn Egan', 'Streetroad 19B', 'Liverpool', 'L1 0AA', 'UK');

Note: Make sure you separate each set of values with a comma ,.

The last three records in the "Customers" table will now look like this:

CustomerID CustomerName ContactName Address City PostalCode Country
92 Cardinal Tom B. Erichsen Skagen 21 Stavanger 4006 Norway
93 Greasy Burger Per Olsen Gateveien 15 Sandnes 4306 Norway
94 Tasty Tee Finn Egan Streetroad 19B Liverpool L1 0AA UK

Want to go beyond the notes?

Join CodingNow 2.0's SQL course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

SQL Insert Into – FAQs

Quick answers about learning SQL Insert Into in SQL.

This free note from CodingNow 2.0 explains SQL Insert Into in SQL — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every SQL topic on CodingNow 2.0, including SQL Insert Into, is 100% free with no signup required.
With focused practice, most students grasp SQL Insert Into in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now