SQL for everyone – Day 1


It is a buzzword we have been hearing in the data world. We are accumulating humongous amounts of data every single day. However, without finding the useful information from the stored data, it is just a piece of word.

Databases are developed to store and retrieve when required. SQL is a declarative programming language for that sole purpose.

Structured Query Language (SQL) is language used to store and manage data in the RDBMS (Relational database management system).

it is best suitable to work with structured data such as tabular data structure. Similarly, it is also used in NoSQL and other applications as well.

SQL is a well standardized language by the American National Standards Institute (ANSI) in 1986 and of the International Organization for Standardization (ISO) in 1987 in the early time and it has been evolving since then.

it is adapted by different organizations and added extension programming language such as T-SQL (Microsoft SQL Server) and PL/SQL (Oracle).

SQL is an easy (Basics) to learn language. it has a set of statements to perform the following operations.

  1. data query language (DQL) – reading data from a table.
  2. data definition language (DDL) – creating, modifying or remove a table.
  3. data control language (DCL) – Granting and revoking the access to a user.
  4. data manipulation language (DML) – add, modify, delete records to a table.

To practice SQL statements, you need a SQL database engine. for simplicity you can use SQLite.

https://www.sqlite.org/index.html - Download and install this software in your computer.

Understand the SQL Statements!

data query language (DQL)

this statement is used to retrieve the data from a table (entity).

Syntax with clauses:

SELECT [TOP n rows] column1, column2, … FROM table_name

WHERE column1 condition

GROUP BY column1

HAVING column1

Example:

SELECT * from Cars;

Here Cars is an entity. It has tuples (records/rows) of attributes (columns)

data definition language (DDL)

It is used for defining the structure of the storage object Table.

The following statements belong to DDL

CREATE – to create an object, a table with attributes to store data of a domain

RENAME – is to rename the table

ALTER – is to add, rename and delete attributes

TRUNCATE – remove all records from the table

DROP – remove an object from the database

How to use DDL statements:

CREATE table_name

(

Column1 data_type,

Column2 data_type

);

Data control language (DCL)

As the name control implies, these statements are used to add or remove access for a particular object.

GRANT – Give access such as select, update, delete, alter and insert permission to a database object.

REVOKE – Takeaway granted access for a user object.

Usage:

GRANT select on [object name] to User name;

REVOKE select on [object name] from user name;

Data manipulation language (DML)

DML statements are for manipulating data in the database tables. You insert, update and delete records in a table.

Usage:

Insert into [table name]

(column1, column2)

Values (value1, value2);

Update [table name]

Set column1 = [value],

Column2 = [value];

Delete from [table name]

Where condition (if deleting selected records);

SQL has become one of the inevitable programming in the data world.

Leave a comment