DML Statements with examples
DML statements defined…
• DML is short name of Data Manipulation Language.
• Deals with data manipulation, and includes most common SQL
statements such SELECT, INSERT, UPDATE, DELETE etc.
• It is used to store, modify, retrieve, delete and update data in
database.
SELECT statements…
• The SELECT statement is used to select records from the table, with or without a condition.
• Select * from student - Gets all records of student table.
• Select * from student where rank > 5 - Gets records with the condition where students' rank is greater than 5.
Insert statements…
• INSERT statement is used to insert a set of values into a database table. Insert statement it used with Values.
• Insert Into Student (Rank, StudentName, Mark) Values (1,’Abbas’,450)
Update statements…
• The UPDATE statement is used to update existing values in a table, which is based on some condition.
• update student set StudentName=’Abbas’ where StudentName=’Imran’
• The query given above will update the student Name from Imran to Abbas.
Delete statements…
• Delete statement is used to delete the existing record in the table, which is based on some condition.
• Delete from Student where StudentName=’Abbas’
• The query given above will delete records which has StudentName as Abbas.