Basics Of SQL (Commands)

Celestial
3 min readDec 17, 2024

--

SQL
Which stands for structured query language , its a programming language as you all know.
Now the question arises why we need sql? whats so important about it ?
so lets tackle these question -

What is sql

So basically SQL is a standard language for manipulating data which held in relational database management systems (RDBMS),now manipulating does not mean what most people do to others but numerically somewhat same
manipulating data is like you’re the pizza chef for example who fixes, and perfects the ingredients (our data) to serve the best dish in short result
now

  • What is RDBMS?

RDBMS is like a super organised digital filing cabinet that stores data in tables.
Imagine it like a magical library where:
1. Books ie (data) are stored in shelves (tables).
2. A catalog system ie (SQL) helps you quickly find, sort, or link the books together.

I hope you all understood what is SQL

Why there is the need of sql?

Imagine you have a huge library full of books (or data), and you need to find just the right book, organise them, or even add new ones. Trying to do this without a librarian would be like searching through thousands of books by hand — messy and time-consuming!

  • Why is SQL important?
    SQL is needed whenever you deal with large amounts of structured data that need to be accessed, organised, and manipulated. It helps keep things organised, efficient, and easy to search.
  • Where we use
    Real-life examples where SQL is used:
    1. Banks: Searching your account details, updating balances, etc.
    2. E-commerce websites: Searching for products, checking availability, placing orders.
    3. Social Media: Managing posts, users, and likes.

Before you all leave — lets learn some Commands

  • DDL (Data Definition Language)
  • DML (Data Manipulation Language)
  • DCL (Data Control Language)
  • TCL (Transaction Control Language)

I will explain u this in simple example — just think that u own a restaurant and you have 4 departments -

  • DDL: Data Definition Language
    Think of DDL as the chef deciding what the kitchen and menu should look like. It’s about designing and building things.
  1. CREATE: “Let’s add a new dish to the menu! How about Spaghetti Carbonara?”
  2. ALTER: “Oh no, the Carbonara needs more cheese. Update that recipe!”
  3. DROP: “Nobody orders the Brussels sprouts salad. Let’s delete it from the menu.”
  4. TRUNCATE: “We’re throwing away all the old orders. Clean slate, folks!”
    DDL is all about setting up the kitchen and the menu, so everything runs smoothly.
  • DML: Data Manipulation Language (The Waitstaff)
    DML is the waitstaff taking orders and serving food. It’s about working with data, not designing it.
  1. INSERT: “Here’s a new order: Table 5 wants two pizzas and a lemonade.”
  2. UPDATE: “Table 5 changed their mind. Make that one pizza and a salad.”
  3. DELETE: “Cancel Table 5’s lemonade; they spilled it and don’t want another.”
  4. SELECT: “What’s Table 3 eating? Let me check… Ah, sushi and green tea!”
  • DCL: Data Control Language (The Bouncer)
    DCL is like the restaurant’s bouncer, who decides who gets access and what they’re allowed to do.DCL makes sure only the right people can get into the kitchen or use the register.
  1. GRANT: “You’re a VIP customer; here’s a free pass to the VIP lounge!”
  2. REVOKE: “Sorry, no more access to the kitchen. You ate all the desserts!”
  • TCL: Transaction Control Language (The Manager’s Undo Button)
    TCL is the manager keeping things under control and fixing mistakes when things go wrong.
  1. COMMIT: “Great! The orders are confirmed. Send them to the kitchen!”
  2. ROLLBACK: “Oops! The wrong order went in. Cancel it and start over.”
  3. SAVEPOINT: “Let’s save our progress in case we mess up later.”
  4. SET TRANSACTION: “Let’s make sure all these changes happen in the right order.”

Till Then, Cya in next blog!!!!

--

--

Celestial
Celestial

Written by Celestial

Uncovering Patterns , Empowering Strategies.

No responses yet