Sunday 13 March 2016

SQL SERVER -- DML Commands -- Part-4

SQL SERVER -- DML Commands -- Part-3

DML Commands:-
                                               DML Stands for Data Manipulation Language.
Following are the DML commands
                   1.INSERT
                   2.UPDATE
                   3.DELETE 
                   4 and MERGE.

INSERT – It is used to insert data into database objects like Table and View.

USE SQLSERVER
GO
INSERT INTO EMP(EMPID, EMPNAME, SAL, DOJ, LOC, GENDER, MagrID, DEPTNO)
VALUES(1,'Santhosh',35000,'01-12-2014','Bangalore','M',3,101)

INSERT INTO EMP
VALUES(2,'Kumari',30000,'11-05-2013','Chennai','F',3,104)

INSERT INTO EMP(EMPID, EMPNAME, SAL, DOJ, LOC, GENDER, MagrID, DEPTNO)
VALUES(3,'Kamesh',75000,'01-12-2012','Mumbai','M',NULL,105)

INSERT INTO EMP(EMPID, EMPNAME, SAL, LOC, GENDER, MagrID, DEPTNO)
VALUES(4,'Arun',44000,'Hyderabad','m',5,103)

INSERT INTO EMP(EMPID, EMPNAME, DOJ, LOC, GENDER, MagrID, DEPTNO)

VALUES(5,'Aishwarya','01-12-2014','Bangalore','f',3,103)



UPDATE– Update is used to update the data present in tables OR Views.

-- UPDATE Command
USE SQLSERVER
GO
UPDATE EMP
SET SAL=50000
WHERE EMPID=5



DELETE– It is used to DELETE the records from the tables.

--DELETE Command
USE SQLSERVER
GO
DELETE FROM EMP
WHERE EMPID=5

MERGE– It is used to INSERT , UPDATE and DELETE all the operations at a time.
















No comments:

Post a Comment