SQL Insert INTO Query

The SQL INSERT INTO query used to insert one OR more records to a table in the database.

SQL INSERT INTO syntax

To insert the values for the specific columns in the table:

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

To insert the values for all the column in the table:

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

Important Description

  • The number of columns and values must be the same.
  • If a column is not specified, the default value for the column is used in SQL INSERT INTO query.
  • The values specified by the INSERT statement must satisfy all the applicable constraints including (primary keys, CHECK constraints, and NOT NULL constraints), etc.
  • If a syntax error occurs, the new row is not added to the table.

Employee Table

A sample of EMPLOYEE records table & the name of table Employee. The column(s) of the Employee table [ID, EMPLOYEE_NAME, EMPLOYEE_EMAIL, ADDRESS, CITY, and COUNTRY]:

ID EMPLOYEE_NAME EMPLOYEE_EMAIL ADDRESS CITY COUNTRY
1 Mark J. mark@gmail.com House 53, Sq. London U.K.
2 Lack Josh lackjosh@gmail.com 2745 road mark Delhi India
3 Kim Juhu kimjuhu@gmail.com Street 587327, 34 House Seoul South Korea
4 Jack Jenifer jenifer@gmail.com 464673 Mataderos Mexico D.F. Mexico
5 McKinley mckinley@gmail.com 54, Road Washington Washington U.S.
6 Alena aln@gmail.com House No. 6563 Tokyo Japan Japan
7 Mack Marina mmk@gmail.com 43 Road, NH San Francisco U.S.
8 Dipak Jha jha@gmail.com Mahanager, 26 Road Lucknow India

INSERT INTO Query Example

INSERT INTO Employee (EMPLOYEE_NAME, EMPLOYEE_EMAIL, ADDRESS, CITY, COUNTRY')
VALUES ('Permila L', 'pl@gmail.com', '49 Cross Road', 'Mumbai', 'India');
ID EMPLOYEE_NAME EMPLOYEE_EMAIL ADDRESS CITY COUNTRY
1 Mark J. mark@gmail.com House 53, Sq. London U.K.
2 Lack Josh lackjosh@gmail.com 2745 road mark Delhi India
3 Kim Juhu kimjuhu@gmail.com Street 587327, 34 House Seoul South Korea
4 Jack Jenifer jenifer@gmail.com 464673 Mataderos Mexico D.F. Mexico
5 McKinley mckinley@gmail.com 54, Road Washington Washington U.S.
6 Alena aln@gmail.com House No. 6563 Tokyo Japan Japan
7 Mack Marina mmk@gmail.com 43 Road, NH San Francisco U.S.
8 Dipak Jha jha@gmail.com Mahanager, 26 Road Lucknow India
9 Permila L pl@gmail.com 49, Cross Road Mumbai India

Policy

GDATAMART.COM is optimized for learning & job information; The users try to improve your knowledge and practical experience through this site but we cannot warrant full correctness of all content... Learn More → | Sitemap →

© 2020 GDATAMART | All Rights Reserved