Insert data using SQL

Last updated: April 26, 2023

Two way is available to insert data in table.

Syntax:

Here you must insert value according to your specify column position :

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

Or

Here you cann't change sequence. You must insert data according to the sequence that you specify when create the table:

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

Insert First Data(using first syntax)

INSERT INTO contact (id, age, mobile, name, address, city, country) VALUES (1, 23, "0171123355", "Murat", "Istambul, Trukey", "Istambul", "Turkey");

Insert Second Data(using second syntax)

INSERT INTO contact VALUES (2, "Jon", 17, "0171123377", "Antalya, Turkey", "Ankara", "Turkey");

If you want to verify data insertion successful or not, then you can show all data and verify result:

SELECT * FROM contact;

 

Insert more data for learning purpose:

Insert 3rd Data(using first syntax)

INSERT INTO contact (id, age, mobile, name, address, city, country) VALUES (3, 45, "017134434", "Kamal", "Dhaka, BD", "Dhaka", "BD");

Insert 4th Data(using first syntax)

INSERT INTO contact (id, age, mobile, name, address, city, country) VALUES (4, 53, "018534958", "Jon", "Dinajpur, BD", "Dinajpur", "BD");

Insert 5th Data(using first syntax)

INSERT INTO contact (id, age, mobile, name, address, city, country) VALUES (5, 35, "01834342", "Rofiqul Islam", "Dinajpur, BD", "Dinajpur", "BD");

Insert 6th Data(using second syntax)

INSERT INTO contact VALUES (6, "Abus Salam", 45, "0174353445", "Doha, Qatar", "Doha", "Qatar");

Insert 7th Data(using second syntax)

INSERT INTO contact VALUES (7, "Siddikur", 45, "0184324234", "Doha, Qatar", "Doha", "Qatar");

Insert 8th Data(using second syntax)

INSERT INTO contact VALUES (8, "Sig Sou", 45, "018344323", "Ningbo, China", "Ningbo", "China");

Related post