Today we are trying to cover Basic commands of DML statement.
For DDL & DML basic Description you can just go through my previous article.
Data manipulation language is subdivided into two categories:
Retrieval commands: SELECT
Editing commands: INSERT, UPDATE, DELETE, MERGE
(DML statement enhanced with some more commands or clause, which we’ll cover in future posts)
Before jump into the DML Command we need to go through a very important and basic clause “WHERE”.
Where clause is used for specifies the condition or filters the result for a table or view. We can choose a specific row for select, update or delete the data by the “where” clause. We are going to use this clause in this article.
Retrieves rows from the database and enables the selection of one or many rows or columns from one or many tables.
SELECT Column list FROM Table WHERE ColumnName = Value
Insert is used to add new row to a table or view.
Insert into TableName (coulumn list)
Values (value list)
Value list is equal to the column list in insert statement for the table,
In Insert list values are expected for all columns except Identity column.
Update is used to change an existing row in a table or view, we can change one or more values in a table depend on condition.
Set ColumnName = ‘NewValue’
Where ColumnName = Value
Delete removes one or more rows or all rows from a table or view.
From far end the DDL command TRUNCATE and DELETE are perform approximate same functionality.
But the main difference between them is, with DELETE we can use where clause to delete specific data from a table but we can’t use where clause with truncate and it removes all data from a table.
There is also some internal storage difference between both of them which we’ll discuss in future post.
Delete From TableName Where ColumnName = Value
By the merge statement we can performs insert, update, or delete operations on a table based on the results of a join with another table.
Overall within a single statement we can insert, update, or delete rows in one table based on differences found in the other table.
In my Next Blog we’ll discuss it deeply.
Hope you will like this post on Microsoft SQL Server.
If you really like reading my blog and understood at least few thing then
please don’t forget to subscribe my blog.
Connect With me on