Thursday, October 30, 2014

SQL INSERT INTO

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

SQL INSERT INTO Syntax

Syntax 1: 
INSERT INTO tablename
VALUES(value1, value2, value3, value4, .......)

***  The number of values should match with the number of columns for the table.

Syntax 2:
INSERT INTO tablename (columnname1, columnname2, columnname3, .....)
VALUES(value1, value2, value3,  .......)

*** This syntax can allow you to insert only specific columns.

SQL INSERT INTO Examples

Tablename = "employees"
Column names are: (id, Name, Department, Gender, Age, Date)
ID No.NameDepartment Gender Age Date Hired
1John SmithSalesM26June 1, 2010
2Jane DoeManagerF30December 1, 2006  
3Mary Lincoln AdminF24April 10, 2010



Example 1 using Syntax 1:
INSERT INTO employees
VALUES(4, 'Diane Park', 'Sales', 'F', 26, 'October 1, 2014');

Example 2 using Syntax 2: (Insert specific columns for a table)
INSERT INTO employees(Name, Gender, Age)
VALUES('Diane Park', 'F', 26);

1 comments:

  1. Hurrah, that's what I was looking for, what a stuff! present here at this webpage, thanks admin of this web page. paypal login

    ReplyDelete

 
Related Posts Plugin for WordPress, Blogger...