Introduction to SQL
SQL (Structured Query Language) is the standard language for interacting with relational databases: creating tables, inserting and updating data, and querying it back out. Almost every relational database speaks a dialect of SQL with a large shared core, and its statements fall into four categories: DDL, DML, DCL and TCL.
SQL, Structured Query Language, is the standard language used to interact with relational databases: creating tables, inserting and updating data, and querying it back out. Almost every relational database (PostgreSQL, MySQL, SQL Server, Oracle, SQLite) speaks a dialect of SQL, with a large shared core that works nearly identically across all of them.
The four broad categories of SQL
- DDL (Data Definition Language): statements that define the structure of the database itself,
CREATE TABLE,ALTER TABLE,DROP TABLE. - DML (Data Manipulation Language): statements that read and write actual rows of data,
SELECT,INSERT,UPDATE,DELETE. - DCL (Data Control Language): statements that manage permissions,
GRANT,REVOKE. - TCL (Transaction Control Language): statements that manage transaction boundaries,
BEGIN,COMMIT,ROLLBACK.
Most day-to-day SQL work, especially for application developers, lives in DML: reading and writing rows.
A worked example
Creating a simple table and running the four core DML statements against it:
CREATE TABLE students (
student_id INT PRIMARY KEY,
name VARCHAR(100),
grade INT
);
INSERT INTO students (student_id, name, grade) VALUES (1, 'Aditi', 90);
INSERT INTO students (student_id, name, grade) VALUES (2, 'Rohan', 75);
SELECT name, grade FROM students WHERE grade > 80;
-- returns: Aditi | 90
UPDATE students SET grade = 82 WHERE student_id = 2;
DELETE FROM students WHERE student_id = 1;
SELECT * FROM students;
-- returns: 2 | Rohan | 82
Each statement does exactly one clear thing: define the shape of the data, add rows, read rows back with a filter, change a row, and remove a row.
Where this matters in real systems
Nearly every backend application, regardless of programming language, ultimately talks to a relational database through SQL, whether written by hand or generated by an ORM (Object-Relational Mapper) like Django's ORM, Hibernate, or ActiveRecord. Even when a team never writes raw SQL directly, understanding what statements the ORM is actually generating underneath is essential for debugging slow queries or unexpected results.
What interviewers actually ask about SQL basics
- "What does SQL stand for, and what is it used for?" Structured Query Language, used to define, query, and modify data in a relational database.
- "What are DDL, DML, DCL, and TCL?" DDL defines structure (CREATE, ALTER), DML manipulates data (SELECT, INSERT, UPDATE, DELETE), DCL manages permissions (GRANT, REVOKE), TCL manages transactions (COMMIT, ROLLBACK).
- "Is SQL the same across every database?" The core is standardized and shared, but each database has its own extensions and quirks (stored procedure syntax, specific functions), so not every statement is portable without changes.
- "What's the difference between DELETE and DROP?" DELETE removes rows from a table but keeps the table itself; DROP removes the entire table, structure and all.
Key takeaways
- SQL is the standard language for defining and working with data in a relational database.
- It splits into DDL (structure), DML (data), DCL (permissions), and TCL (transactions).
- Application developers spend most of their time in DML: SELECT, INSERT, UPDATE, DELETE.
- Most backend applications talk to a database through SQL, whether written directly or generated by an ORM.
More in SQL
Browse all DBMS topics
Log in to save which topics you've read across every subject.
Frequently asked questions
What does SQL stand for, and what is it used for?
Structured Query Language, used to define, query, and modify data in a relational database.
What are DDL, DML, DCL, and TCL?
DDL defines structure (CREATE, ALTER), DML manipulates data (SELECT, INSERT, UPDATE, DELETE), DCL manages permissions (GRANT, REVOKE), TCL manages transactions (COMMIT, ROLLBACK).
Is SQL the same across every database?
The core is standardized and shared, but each database has its own extensions and quirks (stored procedure syntax, specific functions), so not every statement is portable without changes.
What's the difference between DELETE and DROP?
DELETE removes rows from a table but keeps the table itself; DROP removes the entire table, structure and all.