SQL Insert 1: Simple Insert Statement

Look at the below SQL statements. The first one use Pubs informs SQL server that the Queries should performed on the Pubs database. In the below Query we are executing the Insert statement on the Jobs table of the Pubs database. All we specified is the table name jobs and some list of values separated by comma between the open and close parenthesis.

Use Pubs;

Go

 

--Insert values for all column except the one taken care by SQL2005

insert into jobs(15,'Editor 2',10,100);

Select * from Jobs;

 

Pic01.JPG

In the above picture the table Jobs actually has job_id column and we are not inserting the values in the above query for it. This is because that particular column is auto populated key column. We will discuss that in some other article or blog. So in the Insert statement if I am not specifying the column names then I am inserting values for all the columns in the table.

Below is the result of executing the SQL Statement:

Pic02.JPG

 


Ebook Download
View all
SQL Jobs
Read by 0 people
Download Now!
Learn
View all