
For an instructor lead, in-depth look at learning SQL click below.
-**
Welcome to the world of Structured Query Language or SQL, the standard for managing and manipulating relational databases. This blog introduces you to the basics of SQL, focusing on understanding how to use SQL to interact with a database. We assume that you have a basic understanding of databases and programming. If you are completely new to this, consider reading up on relational databases and the basics of programming before you dive into SQL.
**
Introduction to SQL
**
SQL, an acronym for Structured Query Language, is a language used to communicate and manipulate databases. To understand SQL, it’s essential to understand what databases are. A database is an organized collection of data stored and accessed electronically. SQL helps us work with these data in a more structured and easy way, enabling database creation, deletion, fetching rows, modifying rows, etc.
**
Basic SQL Commands
**
There are five types of SQL commands – Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), Transaction Control Command(TCC), and Data Query Language (DQL). For the scope of this blog, we will focus on DDL, DML, and DQL commands.
**
1. Data Definition Language (DDL)
**
The DDL consists of the SQL commands that can be used to define the database schema. It simply deals with descriptions of the database schema and is used to create and modify the structure of database objects in the database. DDL is a set of SQL commands used to create, modify, and delete database structures but not data. For example:
1 2 3 4 5 6 7 8 |
CREATE TABLE Employees ( ID int, Name varchar (255), Age int, Address varchar (255) ); |
**
2. Data Manipulation Language (DML)
**
The DML consists of the SQL commands that deal with the manipulation of data present in the database. DML is used to insert, select, update, and delete data in the database. The “insert” command, for example, is used to insert data into a database, while the “update” command changes specified data within a database:
1 2 3 4 |
INSERT INTO Employees (ID, Name, Age, Address) VALUES (1, 'John Doe', 30, '123 Street, City, State'); |
1 2 3 4 5 |
UPDATE Employees SET Address = '456 Street, City, State' WHERE Name = 'John Doe'; |
**
3. Data Query Language (DQL)
**
The DQL consists of the SQL commands that are used to fetch data from the database. Generally, the command ‘Select’ is used in DQL which allows users to fetch data from a database. For example:
1 2 3 |
SELECT * FROM Employees; |
So, SQL provides vast capabilities for manipulating data. With the foundational understanding of SQL from this blog, you can explore more advanced concepts and uses of SQL. Keep practicing and stay curious!