Introduction to SQL

ARULARASI JARULARASI J
3 min read

Before understanding SQL. Let's try to understand what is data and databases.

What is data?

Data can be texts or numbers written on paper, or it can be bytes and bits inside the memory of electronic devices, or it could be facts that are stored inside a person’s mind.

What is a database?

A database is a collection of organized data, stored and accessed electronically. It is used to store and retrieve information as needed by other software applications.

Some examples of data that can be stored in a database include:

  • Customer information, such as names, addresses, and contact details

  • Employee information, such as names, job titles, and salaries

  • Financial data, such as accounts payable and receivable, budgets, and financial statements

What is SQL (Structured Query Language)?

SQL is a language that helps us to talk to databases and perform various operations like inserting, updating, deleting and retrieving data from the database tables. It is widely used to manage relational databases, which contain multiple tables of data that are related to one another.

Is SQL a programming language?

SQL (Structured Query Language) is a query language, not a programming language.

A query language is used to retrieve and manipulate data in a database, while a programming language is used to write software programs that perform various tasks on a computer. SQL is used primarily for managing and querying relational databases. It is used to insert, update, delete and retrieve data from a database.

SQL is not a general-purpose programming language like C++, Python or Java. It is used specifically for interacting with relational databases and it can't perform operations like loops, variables, and functions that a programming language has. However, some implementations of SQL like PL/SQL (Oracle) and T-SQL (SQL Server) have added some procedural functionality to SQL.

Why do we need SQL?

SQL provides a powerful and efficient way to access and manipulate data stored in a relational database. Some of the main reasons why SQL is important to include:

  1. Data Retrieval - allows you to retrieve specific pieces of data from a relational database based on certain conditions. This makes it easy to extract the information you need for a particular task or analysis.

  2. Data Manipulation - allows you to insert, update, and delete data in a relational database. This allows you to add new data, modify existing data, or remove data that is no longer needed.

  3. Data Definition - provides commands to define the structure of a relational database, including creating and modifying tables, views, indexes, constraints, and other database objects.

  4. Portability - SQL is a standard language that is supported by many different relational database management systems (RDBMS) such as MySQL, Oracle, SQL Server, PostgreSQL, etc. This makes it easy to switch between different databases or share data across different systems.

Types of SQL Statements

  1. Data Definition Language (DDL): These statements are used to define the database schema. They create, alter, and drop database objects such as tables, indexes, and views. Examples of DDL statements include CREATE, ALTER, and DROP.

  2. Data Manipulation Language (DML): These statements are used to manipulate the data within the database. They insert, update, and delete data in existing tables. Examples of DML statements include SELECT, INSERT, UPDATE, and DELETE.

  3. Data Query Language (DQL): These statements are used for retrieving data from the database, such as SELECT statement

  4. Data Control Language (DCL): These statements control the access to the data in a database, such as GRANT and REVOKE.

  5. Data Transaction Language (DTL): These statements manage the changes made by DML statements, such as COMMIT and ROLLBACK

0
Subscribe to my newsletter

Read articles from ARULARASI J directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

ARULARASI J
ARULARASI J