Basic SQL Commands: Complete Beginner Guide
If you're starting your journey into databases, learning basic SQL or MySQL commands is the first and most important step. SQL (Structured Query Language) is the standard language used to interact with databases. MySQL is one of the most popular database management systems that uses SQL.
Whether you're a developer, student, or aspiring data analyst, understanding SQL basics will help you manage data efficiently, build applications, and work with real world databases.
In this complete guide, you'll learn:
What SQL and MySQL are
How to install and set up MySQL
Essential SQL commands with practical examples
Common mistakes beginners make
Benefits of learning SQL
Frequently asked questions (People Also Ask style)
Let’s get started.
What is SQL?
SQL (Structured Query Language) is a programming language used to:
Create databases
Store data
Retrieve data
Update records
Delete records
Manage database permissions
SQL works with relational databases, which store data in tables.
Popular database systems that use SQL include:
MySQL
PostgreSQL
Microsoft SQL Server
Oracle Database
What is MySQL?
MySQL is an open source relational database management system (RDBMS) that uses SQL as its query language.
It is widely used in:
Web development
Content management systems
E-commerce platforms
Enterprise applications
MySQL is known for its speed, reliability, and ease of use.
How to Install and Set Up MySQL
On Ubuntu/Linux
Follow this article to install on Ubuntu How to Install MySQL.
On Windows
Go to the official MySQL website.
Download MySQL Installer.
Run the installer.
Choose "Developer Default".
Set a root password.
Complete installation.
Basic SQL/MySQL Commands (With Practical Examples)
Let’s explore the most important SQL commands every beginner should know.
1. CREATE DATABASE
Creates a new database.
CREATE DATABASE school;Use it:
USE school;2. CREATE TABLE
Creates a table inside a database.
CREATE TABLE students (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100),
age INT,
grade VARCHAR(10)
);3. INSERT INTO
Adds data to a table.
INSERT INTO students (name, age, grade)
VALUES ('geekdas', 18, 'A');Insert multiple rows:
INSERT INTO students (name, age, grade)
VALUES
('Anita', 19, 'B'),
('geekdas', 17, 'A');4. SELECT
Retrieves data from a table.
SELECT * FROM students;Select specific columns:
SELECT name, grade FROM students;With condition:
SELECT * FROM students WHERE grade = 'A';5. UPDATE
Updates existing records.
UPDATE students
SET grade = 'A+'
WHERE name = 'geekdas';6. DELETE
Deletes records from a table.
DELETE FROM students
WHERE name = 'geekdas';IMPORTANT: Always use "WHERE" with DELETE to avoid removing all records.
7. DROP
Deletes database or table permanently.
DROP TABLE students;Or:
DROP DATABASE school;IMPORTANT: Be careful - this cannot be undone.
8. ALTER TABLE
Modifies table structure.
Add a column:
ALTER TABLE students
ADD email VARCHAR(100);9. ORDER BY
Sorts results.
SELECT * FROM students
ORDER BY age DESC;10. LIMIT
Limits number of results.
SELECT * FROM students
LIMIT 5;Practical Real World Example
Let’s say you're building a simple CRM system.
Create database:
CREATE DATABASE crm;
USE crm;Create a customers table:
CREATE TABLE customers (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100),
email VARCHAR(100),
city VARCHAR(50)
);Insert customers:
INSERT INTO customers (name, email, city)
VALUES ('geekdas', 'dev.geekdas@email.com', 'Delhi');Find customers from Delhi:
SELECT * FROM customers WHERE city = 'Delhi';This is how real applications use SQL behind the scenes.
Common Mistakes Beginners Make
Here are typical SQL mistakes to avoid:
1. Forgetting WHERE Clause in DELETE or UPDATE
Wrong:
DELETE FROM students;This deletes everything.
2. Case Sensitivity Confusion
Table names may be case sensitive on Linux servers.
3. Not Using Primary Keys
Always define a "PRIMARY KEY" to uniquely identify records.
4. Ignoring Data Types
Using wrong data types (like storing numbers as VARCHAR) causes performance issues.
5. Not Backing Up Before DROP
Always backup your database before running destructive commands.
Benefits of Learning Basic SQL/MySQL Commands
Learning SQL offers many advantages:
1. High Demand Skill
SQL is required in software development, data analysis, and backend engineering.
2. Works with Most Databases
SQL is universal across systems.
3. Easy to Learn
Compared to programming languages, SQL syntax is simple and readable.
4. Required for Web Development
If you use PHP, Node.js, Python, or Java, you’ll interact with databases using SQL.
5. Career Opportunities
Jobs like:
Database Administrator
Backend Developer
Data Analyst
Data Engineer
All require SQL knowledge.
Conclusion
Learning basic SQL or MySQL commands is the foundation of working with databases. From creating databases to retrieving and updating records, SQL enables you to manage structured data effectively.
Start by practicing:
CREATE
INSERT
SELECT
UPDATE
DELETE
Once you’re comfortable with these commands, you can move toward advanced topics like joins, indexing, stored procedures, and optimization.
The best way to master SQL? Practice daily.