By now it’s probably pretty clear what the SQL language is and what it does. But for the fun of theoretical intellect let do a quick run through of few things. The SQL is a language to used operate and manipulate databases; some of the functions include database creation, deletion, fetching rows and columns, modifying rows, etc.
What is SQL?
First things first, what is SQL ? Well SQL stands for Structured Query Language, which is a computer language for storing, manipulating and retrieving data stored in a relational database. So basically is a language that was developed explicitly for databases, which is pretty neat considering not even a whole country can say they have their own personal language.
All the Relational Database Management Systems (RDMS) like MySQL, MS Access, Oracle, Sybase, Informix, Postgres and SQL Server use SQL as their standard database language.
Just like any other widely used language, SQL has different dialects, such as −
• MS SQL Server using T-SQL,
• Oracle using PL/SQL,
• MS Access version of SQL is called JET SQL (native format) etc.
Why SQL?
SQL is widely popular because it offers the following advantages −
• Give the users the capability to access and manipulate data in the relational database management systems.
• Allows users to define the database and manipulate its structure.
• It can be embedded within other languages using SQL modules, libraries & pre-compilers.
All this without having to spend hours burying one’s self in books trying to learn it, SQL has a vast pool of readily available information on the web.
A Brief History of SQL
• 1970 − Dr. Edgar F. “Ted” Codd of IBM who is known as the father of relational databases, describes a relational model for databases.
• 1974 − Structured Query Language appeared.
• 1978 − System/R is released by IBM after they worked to develop Dr. Codd’s idea.
• 1986 − IBM developed the first prototype of relational database and standardized by ANSI. The first relational database was released by Relational Software which later came to be known as Oracle.
SQL Process
When you are executing an SQL command for any RDBMS, the system does most of the heavy lifting so you don’t have to. It determines the best way to carry out your request and SQL engine figures out how to interpret the task.
There are various components included in this process.
These components are −
• Query Dispatcher
• Optimization Engines
• Classic Query Engine
• SQL Query Engine, etc.
A classic query engine handles all the non-SQL queries, but a SQL query engine won’t handle logical files.
SQL Commands
The standard SQL commands to interact with relational databases are CREATE, SELECT, INSERT, UPDATE, DELETE and DROP. These commands can be classified into the following groups based on their nature −
DDL – Data Definition Language
Used to create and modify the structure of database objects in a database.
DML – Data Manipulation Language
Used for adding (inserting), deleting, and modifying (updating) data in a database
DCL – Data Control Language
Used to control access to data stored in a database.
Let’s show this practically:
Create command
CREATE TABLE customers (
customer_id serial primary key,
customer_name varchar(50) not null,
details text
);
Insert command
INSERT INTO customers (customer_id, customer_name) VALUES
(1, 'Mary'),
(2, 'Joyce'),
(3, 'Esther');
Select command
SELECT from customers where customer_name = ‘Lisa’;
Delete command
Delete from customers where customer_name = ‘Lisa’;
Update command
UPDATE customers
set customer_name = ‘Musa’
where customer_id = 1;