{"id":141,"date":"2019-07-09T03:50:49","date_gmt":"2019-07-08T22:20:49","guid":{"rendered":"https:\/\/techieshouts.com\/?p=141"},"modified":"2022-08-09T19:08:43","modified_gmt":"2022-08-09T13:38:43","slug":"types-of-sql-statements","status":"publish","type":"post","link":"https:\/\/techieshouts.com\/home\/types-of-sql-statements\/","title":{"rendered":"Types of SQL Statements in MS SQL Server"},"content":{"rendered":"\n<p>There are different types of statements that can be executed in SQL Server for different purposes. These are basically categorized into four types<\/p>\n\n\n\n<ol><li>DDL &#8211; Data Definition Language<\/li><li>DML &#8211; Data Manipulation Language<\/li><li>DCL &#8211; Data Control Language<\/li><li>TCL &#8211; Transaction Control Language<\/li><\/ol>\n\n\n\n<div class=\"wp-block-ub-table-of-contents ub_table-of-contents\" data-showtext=\"show\" data-hidetext=\"hide\"><div class=\"ub_table-of-contents-header\"><div class=\"ub_table-of-contents-title\">Types of SQL Statements<\/div><\/div><div style=\"display:block\" class=\"ub_table-of-contents-container ub_table-of-contents-1-column\"><ul><li><a href=\"#0-ddld-ata--definition-language\">DDL(Data Definition Language)<\/a><\/li><li><a href=\"#1-dmldata-manipulation-language\">DML(Data Manipulation Language)<\/a><\/li><li><a href=\"#2-dcldata-control-language\">DCL(Data Control Language)<\/a><\/li><li><a href=\"#3-tcltransaction-control-language\">TCL(Transaction Control Language)<\/a><\/li><\/ul><\/div><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/techieshouts.com\/wp-content\/uploads\/2019\/08\/SQL-Commands.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" width=\"604\" height=\"273\" src=\"https:\/\/techieshouts.com\/wp-content\/uploads\/2019\/08\/SQL-Commands.png\" alt=\"Pic to show types of SQL commands\" class=\"wp-image-515\" srcset=\"https:\/\/techieshouts.com\/wp-content\/uploads\/2019\/08\/SQL-Commands.png 604w, https:\/\/techieshouts.com\/wp-content\/uploads\/2019\/08\/SQL-Commands-300x136.png 300w\" sizes=\"(max-width: 604px) 100vw, 604px\" \/><\/a><\/figure><\/div>\n\n\n\n<h2 id=\"0-ddld-ata--definition-language\">DDL(D<strong>ata<\/strong> Definition Language)<\/h2>\n\n\n\n<p>The name itself suggests that it defines the structure of the database objects. <\/p>\n\n\n\n<p>That is, it is used to create or modify the database or its objects. Some of the DDL commands are&nbsp;<\/p>\n\n\n\n<p><a href=\"https:\/\/techieshouts.com\/create-table-in-sql-server\/\">CREATE<\/a> \u2013 Creates a database or its objects like table, view, SP, etc.&nbsp;<\/p>\n\n\n\n<p><a href=\"https:\/\/techieshouts.com\/alter-table-in-sql-server\/\">ALTER<\/a> \u2013 Modifies the structure of the DB or its objects.&nbsp;<\/p>\n\n\n\n<p>DROP \u2013 Drops the structure of the DB or its objects.&nbsp;<\/p>\n\n\n\n<p>TRUNCATE \u2013 Deletes the data from the table as well as the space allocated for the records. The structure of table remains same.&nbsp;<\/p>\n\n\n\n<p>RENAME \u2013 Renames an object.&nbsp;<\/p>\n\n\n\n<h2 id=\"1-dmldata-manipulation-language\">DML(Data Manipulation Language)<\/h2>\n\n\n\n<p>It deals with the retrieval and manipulation of the data stored in tables. Some of the SQL DML commands are&nbsp;<\/p>\n\n\n\n<p><a href=\"https:\/\/techieshouts.com\/creating-table-with-data\/\">SELECT<\/a> \u2013 Retrieves data from a table.&nbsp;<\/p>\n\n\n\n<p>INSERT \u2013 Inserts data into a table.&nbsp;<\/p>\n\n\n\n<p>UPDATE \u2013 Updates existing data in a table.&nbsp;<\/p>\n\n\n\n<p>DELETE \u2013 Deletes data from the table.&nbsp;<\/p>\n\n\n\n<p>MERGE \u2013 Performs insert or update operation.&nbsp;<\/p>\n\n\n\n<h2 id=\"2-dcldata-control-language\">DCL(Data Control Language)<\/h2>\n\n\n\n<p>It deals with the permissions and privileges of the objects. Two DCL commands are&nbsp;&nbsp;<\/p>\n\n\n\n<p>GRANT \u2013 Provides user access to the database or its objects.&nbsp;<\/p>\n\n\n\n<p>REVOKE \u2013 Restricts the user access to the database or its objects.&nbsp;<\/p>\n\n\n\n<h2 id=\"3-tcltransaction-control-language\">TCL(Transaction Control Language)<\/h2>\n\n\n\n<p>It deals with the transaction within the database. Some of the TCL commands are&nbsp;<\/p>\n\n\n\n<p>COMMIT \u2013 Used to store the changes performed using a transaction.&nbsp;<\/p>\n\n\n\n<p>ROLLBACK \u2013 Used to revert the changes up to the last committed state in case of any error.&nbsp;<\/p>\n\n\n\n<p>SAVEPOINT \u2013 Used to roll the transaction back to a certain point.&nbsp;<\/p>\n\n\n\n\n\n<p>Also, check &#8220;<a href=\"https:\/\/techieshouts.com\/creating-table-with-data\/\">Create table using SELECT in MS SQL Server<\/a>&#8220;<\/p>\n\n\n\n<p>Reference &#8211; <a href=\"https:\/\/social.technet.microsoft.com\/wiki\/contents\/articles\/34477.sql-server-commands-dml-ddl-dcl-tcl.aspx\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"SQL Server statements (opens in a new tab)\">SQL Server statements<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are different types of statements that can be executed in SQL Server for different purposes. These are basically categorized into four types DDL &#8211; Data Definition Language DML &#8211; Data Manipulation Language DCL &#8211; Data Control Language TCL &#8211; Transaction Control Language DDL(Data Definition Language) The name itself suggests that it defines the structure\u2026 <span class=\"read-more\"><a href=\"https:\/\/techieshouts.com\/home\/types-of-sql-statements\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[42,39,40,41],"_links":{"self":[{"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/posts\/141"}],"collection":[{"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/comments?post=141"}],"version-history":[{"count":12,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":595,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/posts\/141\/revisions\/595"}],"wp:attachment":[{"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/media?parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/categories?post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/tags?post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}