Structured Query Language (SQL)
Structured Query Language (SQL) refers to a standard programming language utilized to
extract, organize, manage, and manipulate data stored in relational databases. SQL is thereby
referred to as a database language that can execute activities on databases that consist of
tables made up of rows and columns.
SQL is the most widely used commercial relational database language, designed to be used by
professionals and non-professionals alike. Starting with Oracle in the late 1970s, there have
been many commercial RDBMSs based on SQL, and with an ANSI (American National
Standards Institute) and ISO (International Organization for Standardization) standard, it's
now the formal and de facto language for defining and manipulating relational databases.
SQL plays a crucial role in retrieving relevant data from databases, which can later be used by
various platforms such as Python or R for analysis purposes. SQL can manage several data
transactions simultaneously where large volumes of data are written concurrently.
Top companies owned by Meta Inc., such as Facebook, WhatsApp, and Instagram, all rely
on SQL for data processing and backend storage.
The main characteristics of SQL are:
It's relatively easy to learn.
It's a non-procedural language: you specify what information you require, rather than
how to get it. In other words, SQL does not require you to specify the access methods
to the data.
Like most modern languages, SQL is essentially free-format, which means that parts
of statements don't have to be typed at particular locations on the screen.
The command structure consists of Standard English words such as SELECT,
INSERT, UPDATE, and DELETE.
It can be used by a range of users, including Database Administrators (DBAs),
management personnel, application programmers, and many other types of end-users.
SQL is an important language for a number of reasons:
SQL is the first and, so far, only standard database language to gain wide acceptance.
Nearly every major current vendor provides database products based on SQL or with
an SQL interface.
There is a huge investment in the SQL language both by vendors and by users.
SQL has also become a Federal Information Processing Standard (FIPS), to which
conformance is required for all sales of DBMSs
SQL is used in other standards, and even influences the development of other
standards as a definitional tool.
Objectives of SOL
Create the database and table structures
Perform basic data management tasks, such as the insertion, modification and deletion
of data from the tables
Perform both simple and complex queries.
SQL Commands
SQL commands are instructions used to communicate with the database. It is also used to
perform specific tasks, functions, and queries of data.
SQL commands can be categorized into following types.
a) DDL (Data Definition Language)
b) DML(Data Manipulation Language)
c) TCL (Transaction Control Language)
d) DCL (Data Control Language)
e) DQL (Data Query Language)
The diagram below gives a summary of the five types of SQL commands
a. Data Definition Language (DDL)
Data Definition Language helps you to define the database structure or schema.
All the command of DDL are auto-committed that means it permanently save all the changes
in the database.
Some commands that come under DDL include CREATE, ALTER, DROP and TRUNCATE.
b. Data Manipulation Language
DML commands are used to modify the database. It is responsible for all form of changes in
the database.
The command of DML is not auto-committed that means it can't permanently save all the
changes in the database. They can be rollback.
Some commands that come under DML include INSERT, UPDATE and DELETE.
c. Data Control Language
DCL commands are used to grant and take back authority from any database user. The
commands here include GRANT and REVOKE.
d. Transaction Control Language
TCL commands can only be used with DML commands like INSERT, DELETE and
UPDATE.
Some operations such as CREATE and DROP are automatically committed in the database
that's why they cannot be used with them.
Some commands under TCL include COMMIT, ROLLBACK and SAVEPOINT
e. Data Query Language
DQL is used to fetch the data from the database. It uses only one command that is SELECT
Writing SOL commands
An SQL statement consists of
i. Reserved words - are a fixed part of the SQL language and have a fixed meaning.
They must be spelled exactly as required and cannot be split across lines.
Normally written in upper case
ii. User-defined words - are made up by the user (according to certain syntax rules), and
represent the names of various database objects such as tables, columns, views,
indexes, and so on. Written in lower case.
Portable language: SQL, being a portable language, can be
transferred from one device to another, where the devices can
range from personal computers and servers to laptops and even
some mobile devices. The language is capable of running on
local internet and intranet systems.
Fast query processing: Irrespective of the volume of data, SQL
is capable of inserting, deleting, retrieving, and manipulating
data quickly and efficiently while ensuring data accuracy. This
enables fast data sharing between users.
No coding skills required: SQL does not demand coding skills
like other programming languages. Its user-friendly trait makes
it accessible to all users as they can manage SQL with the help
of keywords such as ‘create,’ ‘insert,’ ‘select,’ ‘update,’ and
others without possessing any programming skills.
Uniform platform with standardized language: SQL uses
English as a standard language; hence, it is easy for all users to
understand, learn, write, and interpret without much difficulty.
The English words and statements make SLQ accessible to
everyone, including people with little or no previous experience.
Offers multiple data views: SQL provides a facility to create
multiple data views, where different users can visualize the
database structure and its content differently.
Open source code. Open source SQL solutions such as
MySQL, MariaDB, and PostGresSQL provide accessible SQL
databases. This attracts the participation of larger communities
at a lower cost.
Top database management system (DBMS) vendors use
SQL: The DBMS systems of top companies such as IBM,
Oracle, and Microsoft use SQL, considering the
comprehensive benefits it offers.
Interactive language: SQL is an interactive and interpretive
language. As such, it reduces the chances of miscommunication
or misunderstanding between users.