Loading
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.

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

CREATE TABLE Students (...);   -- creates a new table
INSERT INTO Students VALUES (...);   -- adds new data
SELECT * FROM Students;   -- reads the data

SQL Commands are how we 'talk' to the database.



How SQL Commands Work

Let us imagine your databse is like a house


ActionReal Life MeaningSQL Equivalent
Build the houseCreate structureCREATE TABLE, ALTER TABLE
Add furnitureInsert or update dataINSERT, UPDATE
Look aroundRetrieve informationSELECT
Give keys to othersManage permissionsGRANT, REVOKE
Undo a changeManage transactionsCOMMIT, ROLLBACK

Each of these tasks uses different types of SQL Commands, which we will learn next.


Example

-- Create a table
CREATE TABLE Students (
    StudentID INT,
    Name VARCHAR(50),
    Age INT
);

-- Insert data
INSERT INTO Students VALUES (1, 'Amit Kumar', 21);

-- View data
SELECT * 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.