Protected by Copyscape Web Copyright Protection Software

Pages

Search This Blog

Wednesday, December 4, 2013

SQL Lesson 5


Lesson 5:

I)  DML

DML means Data Manipulation Language. It is used to manipulate the data means used to insert or update or delete the data. After DML operations we need to apply an explicit commit. There are 3 commands in DML. Insert Update and Delete.

1) INSERT:

It is the first DML command used to insert add the rows into existing table. Before insert we must know the table structure like data type and not null columns, and then only we can insert rows successfully.

Syntax: Insert into table_name values (val1, val2….);

Make sure the order of the values is in the same order as the columns in the table.

Or

Insert into table_name (col1, col2, col4, col5) values (val1, val2, val4, val5);

We can insert values in two ways. In first syntax we must insert all columns values. But by using second syntax we can insert into specific column only and remaining columns replace with null.
Ex: We have EMP table.

Desc Emp;

Select * from EMP;

 Here ‘Select’ is a DQL command will explain in DQL Commands Section in coming lessons.


Now insert one row in that table.

First method:

Insert into Emp values (1,'Rajasekhar','Admin','','01-JAN-1954', 24000, 4000, 10);


Here for MGR column we are inserting null.

Select * from EMP;


Second Method:

Insert into EMP (Empno, ename, Sal) values (1,'Rajasekhar', 4000);

No comments:

Post a Comment