Introduction
In this article, we will learn how to write a SQL insert query.
To Insert data in SQL INSERT INTO statement is used. We can use INSERT INTO in two ways either specify column name with values or only write values without column names.
Syntax
//With column name
INSERT INTO TABLE_NAME (column1, column2, ...columnN) VALUES (value1, value2, ...valueN);
//Without column name
INSERT INTO TABLE_NAME VALUES (value1,value2, ...valueN);
Note: You don’t need to specify the column name if we are going to insert all values in the table with the same order.
Example
The subsequent statements would create two records in the Article table.
INSERT INTO Article (Id,Title) VALUES ('A1', 'Introduction'); INSERT INTO Article (Id,Title) VALUES ('A2', 'Concept of SQL');
We can write the same query without column name,
INSERT INTO Article VALUES ('A1', 'Introduction'); INSERT INTO Article VALUES ('A2', 'Concept of SQL');