Home »
MySQL
MySQL SQL
Learn, what is SQL, why we use SQL, what are the types of SQL commands, common rules to write SQL commands.
Submitted by Apurva Mathur, on September 03, 2022
What is SQL?
Structured query language commonly known as SQL, is a language by which we handle the database. You simply understand this by a thing of humans, as we humans need some language to communicate with each other, in the same way, SQL is the language that communicates with our database. It has some statements which are used to perform the task on the database.
This task can be anything like updating any record, deleting any record, inserting a record, retrieving a record, etc. There are numerous numbers of statements that we can apply according to the situation with the help of SQL.
Although SQL has some standard commands like Select, Insert, Update, Delete, Create, and Drop these commands can help you achieve any situation you want for your database.
Why we use SQL?
- SQL is like a language that helps us with the way the data is in the relational database system.
- SQL statements provide us with many features like create, select, insert, etc which aid us in database creation.
- SQL also set the permission on the tables.
- We use SQL to retrieve the data from the database.
- SQL provides us with high-security features.
- SQL language is so powerful also it helps to handle the database.
What are the types of SQL commands?
The SQL language is divided into four commands, these commands are as follows:
- DDL: Commonly known as Data Definition Language. This deals with the arrangement of a database and by arrangement, I mean the creation of a table, altering a table, and deleting a table. It also performs the tasks which are related to granting or revoking privileges.
The common DDL commands are: CREATE, DROP, ALTER, TRUNCATE, RENAME, REVOKE, GRANT, etc.
We'll study all these commands in detail in upcoming articles.
- DML: Commonly known as Data Manipulation Language. As the name suggests, these commands are used for manipulation/ modifying the data present in the table. It also accesses the data of the table.
Some common DML commands are: DELETE, MERGE, SELECT, UPDATE, INSERT etc.
- DCL: Generally known as Data Control Language. These commands are used for granting or revoking the rights.
Some common DCL commands are: GRANT, REVOKE, etc.
- DQL: Usually known as Data Query Language. Whenever we want to perform any query on our database, we simply use these commands. These commands help us to obtain the data of the table.
Some common DQL commands are: SELECT
Common rules to write SQL commands
- Do remember that SQL commands are not at all case sensitive which means we can enter the query in any case (lower or upper).
- Semicolons are always a good practice while writing SQL commands. Always put semicolons at the ends of the statement.
- SQL commands can be written in a single line and also on multiple lines.
- Always add the IDs (Index) column while making a table. As IDs are always unique so it helps us while performing large queries.