Views in SQL
A view is a virtual table based on the result of an SQL statement. Views can simplify complex queries by encapsulating them as a single object. Here's an example:
sql
CREATE VIEW sales_employees AS
SELECT name, age
FROM employees
WHERE department = 'Sales';
In this example, we're creating a view called "sales_employees" that selects the name and age of all employees who work in the Sales department. We can now query this view as if it were a regular table.
No comments:
Post a Comment