When you start working with databases, you’ll often face situations where you don’t want to expose the entire table directly, but still need to provide specific data in a simplified format. This is where SQL Views come into the picture.
A View in SQL is like a virtual table that is created based on the result of a query. It doesn’t store the data physically but acts like a window to fetch data from one or more tables.

In this blog, we’ll cover:
By the end, you’ll know how to create, use, and manage SQL Views like a pro.
A View is a stored query in the database that can be treated as a table. It doesn’t hold the data itself but fetches it from the base tables.
Think of it as a saved query that you can reuse whenever you want.
For example, if you frequently need to check the names and salaries of employees from the employees table, instead of writing the query every time, you can just create a View and fetch it directly.
There are several reasons why developers and database admins use Views:
1. Simplify Complex Queries
2. Security
3. Reusability
4. Data Abstraction
The basic syntax of a View in SQL is:
CREATE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
Example 1: Creating a Simple View
Suppose we have an employees table:
| emp_id | emp_name | department | salary |
| 1 | Ramesh | IT | 45000 |
| 2 | Priya | HR | 50000 |
| 3 | Aman | IT | 60000 |
| 4 | Neha | Finance | 55000 |
Now, if we want to create a View that shows only the employees from the IT department:
CREATE VIEW IT_Employees AS
SELECT emp_name, salary
FROM employees
WHERE department = 'IT';
This creates a View named IT_Employees.
Now, whenever we run:
SELECT * FROM IT_Employees;
We’ll get:
| emp_name | salary |
| Ramesh | 45000 |
| Aman | 60000 |
Example 2: View with Multiple Tables
Let’s say we have two tables:
employees
| emp_id | emp_name | department |
departments
| dept_id | dept_name | location |
If we want a View to show employee names with their department location:
CREATE VIEW Emp_Department_Info AS
SELECT e.emp_name, d.dept_name, d.location
FROM employees e
JOIN departments d ON e.department = d.dept_id;
Now, a simple:
SELECT * FROM Emp_Department_Info;
gives you all employees with department details.
Updating a View
You can change the definition of an existing View using CREATE OR REPLACE VIEW.
Example:
CREATE OR REPLACE VIEW IT_Employees AS
SELECT emp_name, salary, department
FROM employees
WHERE department = 'IT';
Dropping a View
If a View is no longer required, you can drop it using:
DROP VIEW view_name;
Example:
DROP VIEW IT_Employees;
Imagine an E-commerce Database with tables like customers, orders, and products.
The sales team only needs to see:
Instead of giving them full table access, you create a View:
CREATE VIEW Sales_Report AS
SELECT c.customer_name, o.order_date, p.product_name
FROM customers c
JOIN orders o ON c.customer_id = o.customer_id
JOIN products p ON o.product_id = p.product_id;
Now, the sales team just runs:
SELECT * FROM Sales_Report;
They get exactly what they need without extra details.
SQL Views are an excellent way to simplify queries, secure data access, and improve reusability. By treating them like virtual tables, developers can save time and ensure consistency in database operations.
If you’re preparing for interviews, make sure you understand:
Because SQL Views are a favorite topic of interviewers when testing database knowledge.
Want to master SQL and database design with hands-on projects?
Check out Uncodemy’s SQL Course and boost your career in backend development.
Personalized learning paths with interactive materials and progress tracking for optimal learning experience.
Explore LMSCreate professional, ATS-optimized resumes tailored for tech roles with intelligent suggestions.
Build ResumeDetailed analysis of how your resume performs in Applicant Tracking Systems with actionable insights.
Check ResumeAI analyzes your code for efficiency, best practices, and bugs with instant feedback.
Try Code ReviewPractice coding in 20+ languages with our cloud-based compiler that works on any device.
Start Coding
TRENDING
BESTSELLER
BESTSELLER
TRENDING
HOT
BESTSELLER
HOT
BESTSELLER
BESTSELLER
HOT
POPULAR