GK SOLUTIONS
AI • IoT • Arduino • Projects & Tutorials
DEFEAT THE FEAR

SQL Language Introduction

⏱️ Estimated time: 15 minutes | Difficulty: Beginner

Table of Contents

What is SQL?

SQL (Structured Query Language) is a standard computer language for relational database management and data manipulation. SQL is used to query, insert, update and modify data in relational databases (like MySQL, PostgreSQL, Oracle, SQL Server).

Note on Pronunciation

SQL is pronounced either as "S-Q-L" or as "Sequel". It is a declarative language, meaning you tell the system what data you want, rather than how to retrieve it. The database engine figures out the how!

Why Should We Learn SQL?

Data is the oil of the 21st century. SQL is the machinery used to extract it.

  • Universal Demand: Whether you are a backend developer, data analyst, product manager, or machine learning engineer, querying databases is an essential skill.
  • Allows Large Volume Processing: Unlike Excel, which struggles with millions of rows of data, SQL databases handle staggering amounts of data with rapid retrieval speeds.
  • Standardized: Though there are different "flavors" of SQL (MySQL vs PostgreSQL), the core syntax (SELECT, WHERE, JOIN) is standard across all of them.

First SQL Query (Hello Data)

The "Hello World" of SQL is simply querying all the data from an existing table.

-- Select all columns from the 'users' table
SELECT * FROM users;
Run Query
| id | first_name | last_name | email | |----|------------|-----------|------------------| | 1 | John | Doe | john@example.com | | 2 | Jane | Smith | jane@example.com |
Time Complexity: O(N) where N is the number of rows in the table without indexed filtering.

Explanation of the SQL Query

Let's dissect this simple query.

1

-- (Comments)

Double dashes -- are used to write single-line comments in SQL. The database engine ignores this text.

2

SELECT

The SELECT statement is used to select data from a database. The data returned is stored in a result table, called the result-set.

3

* (Asterisk)

The asterisk character * is a wildcard that means "all columns". This tells the database to return every column present in the table.

4

FROM users;

The FROM clause specifies which table you want to query. In this case, we are querying the table named users. The semicolon ; is the standard way to separate each SQL statement in database systems.

Types of SQL Commands

  • DDL (Data Definition Language): Defines the database schema (e.g. CREATE, DROP, ALTER).
  • DML (Data Manipulation Language): Manipulates the data present in the database (e.g. INSERT, UPDATE, DELETE).
  • DQL (Data Query Language): Used to fetch data from the database (e.g. SELECT).
  • DCL (Data Control Language): Manages who has rights/permissions to the database (e.g. GRANT, REVOKE).
← Overview Next Lesson: WHERE Clause & Filtering →