

{"id":21705,"date":"2018-08-04T03:59:49","date_gmt":"2018-08-04T03:59:49","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=21705"},"modified":"2025-03-29T22:04:20","modified_gmt":"2025-03-29T16:34:20","slug":"sql-tutorial","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/sql-tutorial\/","title":{"rendered":"SQL Tutorial For Beginners | Learn SQL"},"content":{"rendered":"<p>Welcome to SQL Tutorial. You will learn introduction to SQL, history of SQL, Uses of SQL and much more. Let&#8217;s start!!!<\/p>\n<h3>What is SQL?<\/h3>\n<p>SQL, which goes by the full form &#8211; Structured Query Language is programming, or we can say a query language that is used to deal with the relational database operations and queries which could involve manipulating or updating a database or creating a new database.<\/p>\n<p>Major operations on a database are known as CRUD operations i.e., Create, Read, Update and Delete and are a widely used database in the technological world.<\/p>\n<p>The database is required to store the large volumes of data being produced today.<\/p>\n<p>SQL is a powerful tool required by anyone who deals with data on a day-to-day basis. Sql can insert data into a database.<\/p>\n<p>It can search for some data in the database and also it supports updation and deletion of data stored in the database.<\/p>\n<h3>History of SQL<\/h3>\n<p>SQL was first brought into origin by IBM Researcher\u2019s &#8211; Raymond F. Boyce, and Donald D. Chamberlin in the 1970\u2019s and the initial version created by them was called SEQUEL or Structured English Query Language which worked on manipulation and retrieving data from IBM databases.<\/p>\n<p>After commercial testing, IBM released various versions like System\/38, SQL\/DS, and DB2 in 1979, 1981, and 1983, respectively.<\/p>\n<p>In 1986 making a breakthrough, ANSI and ISO adopted the Standard \u201cDatabase Language SQL\u201d.<\/p>\n<h3>Working of SQL<\/h3>\n<p>SQL works on commands and queries made to a Relational database. A relational database signifies that the data would be stored and retrieved in terms of relations or tables.<\/p>\n<p>When we run on a command on SQL workbench or similar software, the command returns us the required results in the form of a table.<\/p>\n<p>Next, we would learn what SQL commands and the types of SQL commands are.<\/p>\n<h3>What Can SQL Do?<\/h3>\n<p>We can use SQL for various operations. Some of them are stated below<\/p>\n<p>1. We can use SQL to run queries on a database.<br \/>\n2. SQL is used to perform CRUD(Create, Retrieve, Update, Delete) operations on a database.<br \/>\n3. SQL is required to create and manage databases.<br \/>\n4. We use SQL to update and manipulate the existing data in the database.<br \/>\n5. SQL can be used to create views over an already existing database table.<br \/>\n6. SQL comes in handy when we need to divide permissions among different users of a database.<br \/>\n7. We are able to perform transactions easily on databases using SQL as it is compatible with almost all programming languages like &#8211; C++, Java, Python, etc.<\/p>\n<h3>Rules to Write SQL Query<\/h3>\n<p>We need to follow certain rules while writing a SQL query :<\/p>\n<p>1. SQL queries are not case sensitive, but generally, we write SQL keywords in Uppercase for better understanding.<br \/>\n2. SQL statements can span in multi lines.<br \/>\n3. SQL follows the principle of tuple relational calculus and the rules of relational algebra.<br \/>\n4. SQL queries are capable of performing almost all actions on the database.<\/p>\n<h3>SQL Processes<\/h3>\n<p>1. When we run a SQL query on the Dbms or the RDBMS, the system looks into the request and tries to find the best possible way to execute it.<br \/>\n2. While a process is executed we need to take care of many components like &#8211; Query dispatcher and engine, optimization engine, etc.<br \/>\n3. SQL queries are not designed to handle the logical files; non SQL queries are interpreted by the classical query engine of sql.<\/p>\n<h3>Uses of SQL<\/h3>\n<p>SQL integration with multiple technologies make it useful for managing and querying data. It is useful in data science and analytics, Machine Learning and AI, Web Development, Big Data and blockchain.<\/p>\n<p>Some of the uses of SQL are as follows:<\/p>\n<p><strong>1. Database Transaction Management:<\/strong> It is used to manage and configure the DBMS containing all sorts of data.<\/p>\n<p><strong>2. Reporting Purpose:<\/strong> SQL queries prove to be highly beneficial when it comes to reporting the facts and figures out of the bulk data stored in the relational Dbms.<\/p>\n<p><strong>3. Manual Analysis:<\/strong> SQL and its queries prove to be highly beneficial when we need to find problems in stored data, and human intervention is needed to correct the same.<\/p>\n<p><strong>4. Business Friendly:<\/strong> SQL provides many built-in aggregate and arithmetic functions which make it easy to use when dealing with large inflow of data and thus heavy calculations.<\/p>\n<h3>SQL Commands and Types<\/h3>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/SQL-Commands-and-Types.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-87122\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/SQL-Commands-and-Types.jpg\" alt=\"SQL Commands and Types\" width=\"1300\" height=\"700\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/SQL-Commands-and-Types.jpg 1300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/SQL-Commands-and-Types-300x162.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/SQL-Commands-and-Types-1024x551.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/SQL-Commands-and-Types-150x81.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/SQL-Commands-and-Types-768x414.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/SQL-Commands-and-Types-720x388.jpg 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/SQL-Commands-and-Types-520x280.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/SQL-Commands-and-Types-320x172.jpg 320w\" sizes=\"auto, (max-width: 1300px) 100vw, 1300px\" \/><\/a><\/p>\n<p>SQL works by running the commands provided by the user.<\/p>\n<p>We can divide the SQL commands into five distinctions based on the functionality they provide:<\/p>\n<h4>1. DDL (Data Definition Language)<\/h4>\n<p>DDL is used to define the structure or schema of the database and to specify additional properties of the data.<\/p>\n<p>These statements define the implementation of the schema and are mostly hidden from the user, also the data stored in the database is made to follow certain constraints.<\/p>\n<p>Some of the DDL commands are as follows :<\/p>\n<p>1. Create: to create objects in the database<br \/>\n2. Alter: alters the structure of the database<br \/>\n3. Drop: delete objects from the database<br \/>\n4. Rename: rename an object<br \/>\n5. Truncate: deletes all the data stored in a table<\/p>\n<h5>CREATE Command in SQL<\/h5>\n<p>Let us make a Student database here to study various available queries.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<p>CREATE TABLE tableName ( columnName1 , datatype(length) , columnName2 , datatype(length), columnName3 , datatype(length));<\/p>\n<p>Command to create Student database :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">CREATE TABLE DataFlair_Employee (\r\nname_emp  varchar(50),\r\npost_emp varchar(50),\r\nemail varchar(50),\r\nage int,\r\nsalary varchar(10)\r\n);\r\n<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/image3-13.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-87145\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/image3-13.png\" alt=\"SQL Introduction\" width=\"1920\" height=\"1032\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/image3-13.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/image3-13-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/image3-13-1024x550.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/image3-13-150x81.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/image3-13-768x413.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/image3-13-1536x826.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/image3-13-720x387.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/image3-13-520x280.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/image3-13-320x172.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>Execution of the above stated DDL command creates the DataFlair_employee table consisting of four columns i.e. Name, Post, Email, Age and Salary.<\/p>\n<h4>2. DML(Data Manipulation Language)<\/h4>\n<p>DML is used for managing data contained in the schema objects. DML\u2019s can be divided into two subtypes :<\/p>\n<p><strong>1. Procedural DML<\/strong>: In these types of DML\u2019s we need to specify the type of data we need and how to get that data.<\/p>\n<p><strong>2. Declarative or Non-Procedural DML:<\/strong> Here, we only need to know what data is required, but the specifications on the process to get the data is not required. The database, on its own, figures out how to get the data efficiently.<\/p>\n<p>Examples of DML Commands :<\/p>\n<p>1. Insert: used to insert data in the database<br \/>\n2. Update: used to modify the existing data in the database<br \/>\n3. Delete: used to delete all the records contained (Note: The space used is not deleted)<br \/>\n4. Merge: used to merge two or more tables or rows.<\/p>\n<p>Example :<\/p>\n<h5>a. Insert Command in SQL<\/h5>\n<p>Insert command is used to populate and add data to the database already existing. We can use the following<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<p>Insert into tableName (columnName1, columnName2, columnName3\u2026.) Values (value1,value2,value3,&#8230;.) ;<\/p>\n<p>Let us populate the database by using the insert command :<br \/>\nInsert into DataFlair_Employee (name_emp , post_emp , email , age , salary)<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Insert into DataFlair_Employee (name_emp , post_emp , email , age , salary)\r\nValues ('Ram' ,  \"Intern\", 'ram@dataflair.com', 21 , '10000' ),\r\n('Shyam', \"Manager\", 'shyam@dataflair.com' , 25 , '25000'),\r\n('Ria', \"Analyst\" , 'ram@dataflair.com', 23 , '20000'),\r\n('Kavya', \"Senior Analyst\" , 'kavya@dataflair.com', 31 , '30000'),\r\n('Aman', \"Database Operator\",' rish@dataflair.com' , 26 , '15000') ;\r\n\r\n<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Insert-data-into-table.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-87114\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Insert-data-into-table.png\" alt=\"Create table in SQL\" width=\"1920\" height=\"1030\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Insert-data-into-table.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Insert-data-into-table-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Insert-data-into-table-1024x549.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Insert-data-into-table-150x80.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Insert-data-into-table-768x412.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Insert-data-into-table-1536x824.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Insert-data-into-table-720x386.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Insert-data-into-table-520x279.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Insert-data-into-table-320x172.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>Executing this Insert statement populates our database and inserts the record of five employees in our database.<\/p>\n<h5>b. Update Command in SQL<\/h5>\n<p>The update command is used to change the data that is already saved into the database. This can be done by the following<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<p>UPDATE tableName SET column1 = value1, column2 = value2,&#8230; where condition;<\/p>\n<p>Let us update the salary of Ram and change his age to 26 , the command is as follows :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Update dataflair_employee SET salary = 12000 , age = 26 where name_emp = 'Ria'  ;<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Update-data.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-87115\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Update-data.png\" alt=\"Update command in SQL\" width=\"1920\" height=\"1030\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Update-data.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Update-data-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Update-data-1024x549.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Update-data-150x80.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Update-data-768x412.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Update-data-1536x824.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Update-data-720x386.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Update-data-520x279.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Update-data-320x172.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<h5>c. Delete Command in SQL<\/h5>\n<p>Delete command is used to delete the existing records of a database. This can be done by the following<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<p>DELETE FROM table_name WHERE condition;<\/p>\n<p>Let us delete the record corresponding to Kavya; we can get to this by the following command<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">DELETE from  dataflair_employee WHERE name_emp = 'Kavya' ;<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Delete-data-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-87116\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Delete-data-1.png\" alt=\"delete command in SQL\" width=\"1920\" height=\"1030\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Delete-data-1.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Delete-data-1-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Delete-data-1-1024x549.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Delete-data-1-150x80.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Delete-data-1-768x412.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Delete-data-1-1536x824.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Delete-data-1-720x386.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Delete-data-1-520x279.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Delete-data-1-320x172.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<h4>3. DQL (Data Query Language)<\/h4>\n<p>DQl is also known as the Data Query language. It is used to retrieve the data stored in the database created by us and the data we store in the database.<\/p>\n<h5>a. Select Command in SQL<\/h5>\n<p>Let us now display the Student Table that we created.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<p>Select * from tableName ;<\/p>\n<p>after executing this command, we can view all the columns and all the data stored in the table.<\/p>\n<p>Example:<br \/>\na. SELECT * from DataFlair_employee : helps in viewing all the data i.e., all rows and columns.<a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-87117\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-1.png\" alt=\"Select query in SQL\" width=\"1920\" height=\"1030\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-1.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-1-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-1-1024x549.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-1-150x80.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-1-768x412.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-1-1536x824.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-1-720x386.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-1-520x279.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-1-320x172.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>b. SELECT * from DataFlair_employee LIMIT 2; returns data contained in two rows of the database.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-with-Limit-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-87119\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-with-Limit-1.png\" alt=\"SQl Select query with Limit \" width=\"1920\" height=\"1030\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-with-Limit-1.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-with-Limit-1-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-with-Limit-1-1024x549.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-with-Limit-1-150x80.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-with-Limit-1-768x412.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-with-Limit-1-1536x824.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-with-Limit-1-720x386.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-with-Limit-1-520x279.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-with-Limit-1-320x172.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>c<strong>.<\/strong> Select name_emp , Age from DataFlair_employee : returns the data stored in the studentName and Age column of the Student database.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-87120\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-3.png\" alt=\"SQL Select query\" width=\"1920\" height=\"1030\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-3.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-3-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-3-1024x549.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-3-150x80.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-3-768x412.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-3-1536x824.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-3-720x386.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-3-520x279.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Select-query-3-320x172.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>These statements help in viewing the database in various aspects and different views.<\/p>\n<h4>4. TCL (Transaction Control Language)<\/h4>\n<p>TCL commands are useful to handle transactions in the database.<\/p>\n<p>These are used to manage and track the changes made by DML statements , these can be grouped together into logical transactions.<\/p>\n<p>Example:<br \/>\n<strong>1. Commit:<\/strong> used to permanently save any transaction into the database.<br \/>\n<strong>2. Rollback:<\/strong> used to restore the database to the last committed state and is also used with the Savepoint command to move over to any saved state in a transaction.<br \/>\n<strong>3. Savepoint:<\/strong> It is used to temporarily store a transaction so that we can move to the point we need whenever desired.<\/p>\n<h4>5. DCL (Data Control Language)<\/h4>\n<p>DCL commands are similar to the computer programming language in syntax. They are a component of the Structured Query Language.<\/p>\n<p>While using DCL commands, we need to be cautious as some database\u2019s don\u2019t allow rollback command on the DCL command.<\/p>\n<p>One such example is the Oracle database &#8211; when we execute DCL on an oracle database it results in an implicit commit and thus rollback is not allowed.<\/p>\n<p>Example :<br \/>\n<strong>1. Grant:<\/strong> used to allow a specific set of users to perform some specified tasks.<br \/>\n<strong>2. Revoke:<\/strong> used to cancel all the previously granted or denied permissions.<\/p>\n<h3>Summary<\/h3>\n<p>In this article, we have understood the basic introduction of what SQL is and how it is useful to us and where it is used.<\/p>\n<p>We have studied the history of SQL and types of queries available in SQL i.e.<\/p>\n<p>1. DDL &#8211; Data Definition Language<br \/>\n2. DML &#8211; Data Manipulation Language<br \/>\n3. DQL &#8211; Data Query Language<br \/>\n4. TCL &#8211; Transaction Control Language<br \/>\n5. DCL &#8211; Data Control Language<\/p>\n<p>We understood that SQL is a programming language used to handle and manage the activities related to a database i.e., the CRUD operations &#8211; Create, Retrieve, Update and Delete, and we have also discussed the commands related to the various operations.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to SQL Tutorial. You will learn introduction to SQL, history of SQL, Uses of SQL and much more. Let&#8217;s start!!! What is SQL? SQL, which goes by the full form &#8211; Structured Query&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":87105,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66],"tags":[2677,2827,4411,5672,8179,9034,13397,13414,13445,13455,13456,13464,13582,13951,15213,15972,16142],"class_list":["post-21705","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sql","tag-commands-in-sql","tag-components-of-sql","tag-examples-of-sql","tag-history-of-sql","tag-learn-sql","tag-need-of-sql","tag-sql","tag-sql-commands","tag-sql-definition","tag-sql-evolution","tag-sql-examples","tag-sql-history","tag-sql-tutorial","tag-structured-query-language","tag-use-of-sql","tag-what-is-sql","tag-why-do-we-use-sql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL Tutorial For Beginners | Learn SQL - DataFlair<\/title>\n<meta name=\"description\" content=\"SQL Tutorial For beginners, Structured Query language, what is SQL, need for SQL, uses of Structured Query Language, SQL Commands, SQL History\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/sql-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Tutorial For Beginners | Learn SQL - DataFlair\" \/>\n<meta property=\"og:description\" content=\"SQL Tutorial For beginners, Structured Query language, what is SQL, need for SQL, uses of Structured Query Language, SQL Commands, SQL History\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/sql-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-04T03:59:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-03-29T16:34:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Introduction-to-SQL.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL Tutorial For Beginners | Learn SQL - DataFlair","description":"SQL Tutorial For beginners, Structured Query language, what is SQL, need for SQL, uses of Structured Query Language, SQL Commands, SQL History","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/sql-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"SQL Tutorial For Beginners | Learn SQL - DataFlair","og_description":"SQL Tutorial For beginners, Structured Query language, what is SQL, need for SQL, uses of Structured Query Language, SQL Commands, SQL History","og_url":"https:\/\/data-flair.training\/blogs\/sql-tutorial\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-08-04T03:59:49+00:00","article_modified_time":"2025-03-29T16:34:20+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Introduction-to-SQL.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/sql-tutorial\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/sql-tutorial\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89"},"headline":"SQL Tutorial For Beginners | Learn SQL","datePublished":"2018-08-04T03:59:49+00:00","dateModified":"2025-03-29T16:34:20+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/sql-tutorial\/"},"wordCount":1650,"commentCount":24,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/sql-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Introduction-to-SQL.jpg","keywords":["Commands in SQL","Components of SQL","Examples of SQL","History of SQL","Learn SQL","need of SQL","SQL","SQL Commands","SQL Definition","SQl Evolution","SQL Examples","SQL History","SQL Tutorial","Structured Query language","Use of SQL","What is SQL","Why do we use SQL"],"articleSection":["SQL Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/sql-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/sql-tutorial\/","url":"https:\/\/data-flair.training\/blogs\/sql-tutorial\/","name":"SQL Tutorial For Beginners | Learn SQL - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/sql-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/sql-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Introduction-to-SQL.jpg","datePublished":"2018-08-04T03:59:49+00:00","dateModified":"2025-03-29T16:34:20+00:00","description":"SQL Tutorial For beginners, Structured Query language, what is SQL, need for SQL, uses of Structured Query Language, SQL Commands, SQL History","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/sql-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/sql-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/sql-tutorial\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Introduction-to-SQL.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Introduction-to-SQL.jpg","width":1200,"height":628,"caption":"Introduction to SQL Tutorial"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/sql-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"SQL Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/sql\/"},{"@type":"ListItem","position":3,"name":"SQL Tutorial For Beginners | Learn SQL"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"The DataFlair Team provides industry-driven content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our expert educators focus on delivering value-packed, easy-to-follow resources for tech enthusiasts and professionals.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam2\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/21705","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=21705"}],"version-history":[{"count":9,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/21705\/revisions"}],"predecessor-version":[{"id":144678,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/21705\/revisions\/144678"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/87105"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=21705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=21705"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=21705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}