What Are SQL Commands-tutorial
Now that you know how to create databases and tables, it is time to learn how we actually communicate with the database.
How SQL Commands Work
Let us imagine your databse is like a house
These are all different SQL commands with different purposes.
Think of a database as a smart assistant that understands a specific language that language is SQL (Structured Query Language), and the words or instructions you give it are called commands.
Every time you:
- create a new table,
- insert a record,
- fetch some data, or
- delete something,
you are using SQL Commands to tell the database what to do.
What is an SQL Command?
An SQL Command is simply an instruction or statement you give to the database.
It tells the database what action to perform
Example
Example
CREATE TABLE Students (...); -- creates a new tableINSERT INTO Students VALUES (...); -- adds new dataSELECT * FROM Students; -- reads the dataSQL Commands are how we 'talk' to the database.
How SQL Commands Work
Let us imagine your databse is like a house
| Action | Real Life Meaning | SQL Equivalent |
|---|---|---|
| Build the house | Create structure | CREATE TABLE, ALTER TABLE |
| Add furniture | Insert or update data | INSERT, UPDATE |
| Look around | Retrieve information | SELECT |
| Give keys to others | Manage permissions | GRANT, REVOKE |
| Undo a change | Manage transactions | COMMIT, ROLLBACK |
Each of these tasks uses different types of SQL Commands, which we will learn next.
Example
Example
-- Create a tableCREATE TABLE Students ( StudentID INT, Name VARCHAR(50), Age INT);
-- Insert dataINSERT INTO Students VALUES (1, 'Amit Kumar', 21);
-- View dataSELECT * FROM Students;These are all different SQL commands with different purposes.
Why Categorize Commands?
SQL has many commands, but not all do the same job.
Some define the structure, others handle data, and some manage permissions or transactions.
That’s why SQL commands are divided into types, so you can easily understand which command is used for what.
Two Minute Drill
- SQL Commands = Instructions to communiate with databases.
- They help you create, store, retrieve and manage data.
- Commands are grouped into categories based on what they do.
- Real life analogy --> Databae = house, SQL commands = your instructions.