• Home
  • Jobs
  • Courses
  • Certifications
  • Companies
  • Online IDE
  • Login
  • Signup
MYTAT
  • Home
  • Jobs
  • Courses
  • Certifications
  • Companies
  • Online IDE
  • Login
  • Signup
SQL
  • Introduction To SQL
  • SQL Syntax
  • SQL SELECT Statement
  • SQL SELECT DISTINCT Statement
  • SQL WHERE Clause
  • SQL AND, OR And NOT Operators
  • SQL ORDER BY Keyword
  • SQL INSERT INTO Statement
  • SQL NULL Values
  • SQL UPDATE Statement
  • SQL DELETE Statement
  • SQL TOP, LIMIT, FETCH FIRST Or ROWNUM Clause
  • SQL MIN() And MAX() Functions
  • SQL COUNT(), AVG() And SUM() Functions
  • SQL LIKE Operator
  • SQL Wildcards
  • SQL IN Operator
  • SQL BETWEEN Operator
  • SQL Aliases
  • SQL Joins
  • SQL INNER JOIN Keyword
  • SQL LEFT JOIN Keyword
  • SQL RIGHT JOIN Keyword
  • SQL FULL OUTER JOIN Keyword
  • SQL Self Join
  • SQL UNION Operator
  • SQL GROUP BY Statement
  • SQL HAVING Clause
  • SQL EXISTS Operator
  • SQL ANY And ALL Operators
  • SQL SELECT INTO Statement
  • SQL INSERT INTO SELECT Statement
  • SQL CASE Statement
  • SQL NULL Functions
  • SQL Stored Procedures For SQL Server
  • SQL Comments
  • SQL Operators
  • SQL CREATE DATABASE Statement
  • SQL DROP DATABASE Statement
  • SQL BACKUP DATABASE For SQL Server
  • SQL CREATE TABLE Statement
  • SQL DROP TABLE Statement
  • SQL ALTER TABLE Statement
  • SQL Constraints
  • SQL NOT NULL Constraint
  • SQL UNIQUE Constraint
  • SQL PRIMARY KEY Constraint
  • SQL FOREIGN KEY Constraint
  • ALTER TABLE Orders DROP CONSTRAINT FK_PersonOrder;
  • SQL DEFAULT Constraint
  • SQL CREATE INDEX Statement
  • SQL AUTO INCREMENT Field
  • SQL Working With Dates
  • SQL Views
  • SQL Injection
  • SQL Hosting
  • SQL Data Types For MySQL, SQL Server, And MS Access
  • Home
  • Courses
  • SQL
  • SQL INSERT INTO Statement

SQL INSERT INTO Statement

Previous Next

SQL INSERT INTO Statement

The SQL INSERT INTO Statement

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

INSERT INTO Syntax

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

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

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

2. If you are adding values for all the columns of the table, you do not need to specify the column names in the SQL query. However, make sure the order of the values is in the same order as the columns in the table. Here, the INSERT INTO syntax would be as follows:

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



Practice Excercise Practice now

Demo Database

Below is a selection from the "Customers" table in the Northwind sample database:

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



Practice Excercise Practice now

INSERT INTO Example

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

Example

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

The selection from the "Customers" table will now look like this:

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
92 Cardinal Tom B. Erichsen Skagen 21 Stavanger 4006 Norway

Did you notice that we did not insert any number into the CustomerID field?
The CustomerID column is an auto-increment field and will be generated automatically when a new record is inserted into the table.



Practice Excercise Practice now

Insert Data Only In Specified Columns

It is also possible to only insert data in specific columns.

The following SQL statement will insert a new record, but only insert 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 selection from the "Customers" table will now look like this:

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
92 Cardinal null null  Stavanger null Norway
 



Practice Excercise Practice now

Previous Next
COMPANY
  • About us
  • Careers
  • Contact Us
  • In Press
  • People
  • Companies List
Products
  • Features
  • Coding Assessments
  • Psychometric Assessment
  • Aptitude Assessments
  • Tech/Functional Assessments
  • Video Assessment
  • Fluency Assessment
  • Campus
 
  • Learning
  • Campus Recruitment
  • Lateral Recruitment
  • Enterprise
  • Education
  • K 12
  • Government
OTHERS
  • Blog
  • Terms of Services
  • Privacy Policy
  • Refund Policy
  • Mart Category
Partner
  • Partner Login
  • Partner Signup

Copyright © RVR Innovations LLP 2025 | All rights reserved - Mytat.co is the venture of RVR Innovations LLP