Hello and welcome all to a new series to understand SQL statements in simpler ways. In this series, we will try to learn about Data, Database, and SQL statements along with their syntax, execution, and examples. Before understanding the commands of SQL, we have to learn some basics about SQL. And before we learn about SQL, let us understand what SQL is used for.
What is Data?
In simple words, data can be a piece or collection of information or we can also say that data is facts related to any object in consideration. For example, your name, age, height, weight, etc. are some data related to you. A picture, image, file, pdf, etc. can also be considered data.
What is a Database?
A database is a systematic collection of data. They support electronic storage and manipulation of data. Databases make data management easy.
Let us discuss a database example: An online telephone directory uses a database to store data of people, phone numbers, and other contact details. Your electricity service provider uses a database to manage billing, client-related issues, handle fault data, etc.
Let us also consider Facebook. It needs to store, manipulate, and present data related to members, their friends, member activities, messages, advertisements, and a lot more. We can provide countless examples of the usage of databases.
Now, to access, manage or modify the data in the database, we need a medium or a language to make the database understand our requirement, that medium or language is SQL.
What is SQL?
SQL stands for Structured Query Language. SQL is used to create, remove, and alter the database and database objects in a database management system and to store, retrieve, and update the data in a database. SQL is a standard language for creating, accessing, and manipulating database management systems. SQL works for all modern relational database management systems, like SQL Server, Oracle, MySQL, etc. Data is stored in the form of tables in SQL. And the table is divided into several columns according to requirement. So now that we have understood SQL and its use, let’s move ahead to know about the types of SQL statements.
Types of SQL Commands
SQL commands can be categorized into five categories based on their functionality and uses:
1. Data Definition Language (DDL)
DDL commands are used for creating and altering the database and database objects in the relational database management system, like CREATE DATABASE, CREATE TABLE, ALTER TABLE, etc. The most used DDL commands are CREATE, DROP, ALTER, and TRUNCATE.
2. Data Manipulation Language (DML)
DML commands are used for manipulating data in a relational database management system. DML commands are used for adding, removing, and updating data in the database system, like INSERT INTO TableName, DELETE FROM TableName, UPDATE tableName set data, etc. The most used DML commands are INSERT INTO, DELETE FROM, and UPDATE.
3. Data Query Language(DQL)
DQL command is used for fetching the data. DQL command is used for selecting data from the table, view, temp table, table variable, etc. There is only one command under DQL which is the SELECT command.
4. Data Control Language(DCL)
DCL stands for data control language. DCL commands are used for providing and taking back access rights to the database and database objects. DCL command is used for controlling the user’s access to the data. The most used DCL commands are GRANT and REVOKE.
5. Transaction Control Language(TCL)
TCL commands are used for handling transactions in the database. Transactions ensure data integrity in the multi-user environment. TCL commands can roll back and commit data modification in the database. The most used TCL commands are COMMIT, ROLLBACK, SAVEPOINT, and SET TRANSACTION.
So, here we come to the end of the first part of the SQL series blog in which we understood what is Data, Database, SQL, why SQL is required, and what different types of SQL commands are. I hope you liked it and stay tuned for another series wherein we will explore more about the different types of SQL commands.