What is SQL? A Beginnerโ€™s Guide to SQL with Examples

SQL (Structured Query Language) is the standard programming language used to interact with relational databases. It allows users to query, manipulate, and manage data efficiently. Whether youโ€™re using Oracle, MySQL, SQL Server, or PostgreSQL, SQL is the universal gateway to your database.

In this guide, weโ€™ll cover:

  • What is SQL and why it’s important

  • Types of SQL statements

  • SQL syntax with real-world examples

  • Tools to run SQL in Oracle

  • Why learning SQL is essential

What is SQL?

SQL stands for Structured Query Language. Itโ€™s a domain-specific language designed to manage and manipulate relational data stored in database systems.

SQL allows users to:

  • SELECT data from tables

  • INSERT new data

  • UPDATE existing records

  • DELETE unwanted rows

  • Define and alter database objects (tables, views, etc.)

  • Control access and user permissions

SQL โ€“ The Gateway to the Database

SQL is considered a Fourth-Generation Language (4GL), meaning it is designed to be easy to use, even for non-programmers. Instead of writing complex logic, you simply describe what data you want, and SQL fetches it.

Key Benefits:

  • Human-readable syntax

  • Cross-platform (supported by almost all RDBMS)

  • Efficient for data handling

  • Declarative nature: You state what you want, not how to get it

A Brief History of SQL

  • SQL was developed in the 1970s by IBM, based on Dr. E.F. Coddโ€™s relational model.

  • Initially known as SEQUEL, it later became SQL.

  • It is now standardized by ANSI (American National Standards Institute).

  • Oracle adopted and extended SQL with its own tools like SQL*Plus.

SQL*Plus โ€“ Oracle's SQL Interface

Oracle provides SQL*Plus as a utility to run SQL and PL/SQL commands. It comes in multiple forms:

  1. Command Line โ€“ via DOS or Unix terminal
  2. GUI Tools โ€“ like SQL Developer, SQL Worksheet, or Enterprise Manager

  3. Web-Based โ€“ iSQL*Plus (available from Oracle 10g onward)

These tools allow you to connect and interact with both local and remote Oracle databases.

SQL Syntax Examples

SELECT โ€“ Fetch Data

SELECT first_name, salary FROM employees WHERE department_id = 10;

INSERT โ€“ Add New Row

INSERT INTO employees (employee_id, first_name, salary) 
VALUES (101, 'Amit', 50000);

UPDATE โ€“ Modify Data

UPDATE employees SET salary = 60000 WHERE employee_id = 101;

DELETE โ€“ Remove a Row

DELETE FROM employees WHERE employee_id = 101;

Types of SQL Statements

SQL commands can be grouped into five main categories:

  1. Data Query Language (DQL)

    • Used to query the database.

Examples:

SELECT * FROM employees;

   2. Data Definition Language (DDL)

    • Used to define and modify database structure.

    • Commands: CREATE, ALTER, DROP, TRUNCATE

Examples:

CREATE TABLE students (id NUMBER, name VARCHAR2(50));

   3. Data Manipulation Language (DML)

    • Used to manipulate data within tables.

    • Commands: INSERT, UPDATE, DELETE

Examples:

UPDATE employees SET salary = 55000 WHERE id = 101;

   4. Transaction Control Language (TCL)

    • Manages transactions in the database.

    • Commands: COMMIT, ROLLBACK, SAVEPOINT

Examples:

COMMIT;

   3. Data Control Language (DCL)

    • Controls access to data.

    • Commands: GRANT, REVOKE

Examples:

GRANT SELECT ON employees TO hr_user;

Tools to Run SQL in Oracle

ToolDescription
SQL*Plus CLICommand-line interface for running SQL & PL/SQL commands
iSQL*PlusWeb-based version of SQL*Plus (Oracle 10g)
SQL DeveloperGUI tool for running and debugging SQL/PLSQL
Enterprise ManagerWeb GUI to monitor and manage the database

Why Learn SQL?

  • Essential skill for developers, database administrators (DBAs), analysts, and testers

  • Platform-independent โ€“ works across Oracle, MySQL, PostgreSQL, SQL Server, and more

  • Foundation of PL/SQL and many back-end systems

  • Required for data analysis, web development, ERP systems, and much more

  • Vital for reporting, automation, testing, and decision-making

Final Thoughts

SQL is more than just a language โ€” itโ€™s the foundation of modern data management. Whether you’re querying, updating, or managing databases, SQL gives you full control over your data.

By mastering the basics shown in this guide and exploring tools like SQL Developer or SQL*Plus, youโ€™re on your way to becoming a skilled database professional.

Scroll to Top