Labels

Saturday, 19 December 2015

DML Commands - Insert - Update - Delete in SQL

                                       Data Manipulation Language (DML)

DML is the second sub-language in SQL which is used to manipulate the data with in the table.This language contains 3 commands

                                * Insert
                                * Update
                                * Delete

Note: 

Except Truncate all DDL commands will works on structure of the table.
All DML commands will works on DATA in the table .

Insert:
                This command is used to insert the records into the existing table. using this method we can insert the data into the table in 2 methods

                * Explicit Method                                             * Implicit Method

Explicit Method:

                In this method the user has to enter all the values into all columns without omitting any column data i.e nof columns=nof rows

Syntax: 
              Insert  <Table Name> values (CN1,CN2,CN3.........)
Ex:        
              Insert into emp values(101,'sai',37400)

Note: 
         
         In SQL Server into keyword is an optional during insertion .

Implicit Method :

                In this method we can enter values at required columns in the table. So that the user has the facility to enter the values in a specific column. If you donot enter the values in any particular column that column automatically takes NULL.NULL is not equals to zero and NULL is not equal to Space

Syntax: 
             Insert into <Table Name> (CN1,CN2) values(value1,value2)

Ex: 
           Insert into emp (empid,ename) values(1001,'optimize)

Update :

              Update command is used to update 1/more records in an existing table

Syntax: 
            
             Update <Table Name> set columname=value where <condition>

Ex: 
            Update emp set sal=4500 where ename='optimize'

NOTE: 

You can use update command without where clause , by writing update command in this method all records are updated  at a time it is meaning less

Delete :

This command is used to delete 1/more or all records at a time from an existing table

Syntax to delete all records at a time

Delete from <Table Name> 

Syntax to delete only one record at a time

Delete from <Table Name> where <condition>

3 comments:

  1. Its very informative . Thanks for posting this Article

    ReplyDelete
    Replies
    1. Glad to hear your feedback.Keep in touch with blog for more informtion.

      Delete
    2. Glad to hear your feedback.Keep in touch with blog for more informtion.

      Delete